danielgindi / node-csv-reader

A CSV stream reader, with many many features, and ability to work with the largest datasets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clarity on how quotes are handled when used as text qualifier

zachsa opened this issue · comments

Hi - thank you for the library!

I want to use it to parse a CSV that has unescaped newline chars in it - fields that have this are wrapped in quotes.

How are quotes treated if I specify that newlines fields are wrapped in quotes? For example this line from a CSV:

field1,field2,"this is
a field with a newline char", "This is "another field"
with a newline char",field5

Will quotes be ignored if they are not placed next to a delimiter (I would like this to be the case)?

It handles them mostly like Microsoft Excel does. So yes, quotes will be ignored if they are just somewhere inside the field and not next to a delimiter.
But your CSV here is invalid AFAIK, as the quotes inside the quotes should be escaped

Thanks - I don 't actually know that there are quotes inside the quotes that I'm parsing (it's a freeform text field so there may be), so I can't guarantee that they will be escaped (regardless of whether or not they should/shouldn't be).

Well if you are using a proper CSV writer then it should be escaped automatically :-)
Anyway just try, see if it works for you, and you can always PR...