asafdav / ng-csv

Simple directive that turns arrays and objects into downloadable CSV files
MIT License
573 stars 215 forks source link

Text delimiter ignores field separator #144

Open rlach opened 8 years ago

rlach commented 8 years ago

If you set field-separator then the delimiter will be added to fields that use coma, regardless of what field-separator is used. Expected behavior is to add text-delimiter to fields that use field separator character.

Example: Let's have data like this:

{
   fieldA: 'I like apples, really',
   fieldB: 'if(a) return b; if(b) return a;'
}

With coma as field-separator and " as field-delimiter we get proper csv:

"I like apples, really",if(a) return b; if(b) return a;

Which is 2 fields. But if we instead use semicolon as field-separator and " as field-delimiter we get:

"I like apples, really";if(a) return b; if(b) return a;

Which is 4 fields: [ "I like apples, really", "if(a) return b", "if(b) return a", "" ]. Expected value in that case is actually:

I like apples, really;"if(a) return b; if(b) return a;"

Which is proper 2 fields.