-
Notifications
You must be signed in to change notification settings - Fork 166
Automatic rowDelimiter discovery should ignore newlines in quoted fields #142
Comments
Also, am I mistaken or are the constants 'auto', 'unix', 'mac', 'windows', 'unicode' never recognized for rowDelimiter, and instead treated as literals? |
They are literal and are converted to rowDelimiter, for exemple, the value "windows" is converted to "\r\n". |
When I execute your sample, I get
Which seems to be the expected behavior unless i'm missing something. |
Are you sure you are running the same code? Here is an online repro: RE: constants, the string literal 'windows' does not appear in source: so i'm wondering where the conversion happens. In fact, if I peek at the parser's options I can see that the value is still 'windows': > let options = {delimiter: '\t', rowDelimiter: 'windows'}
> console.log(csvParse(content, options, () => null).options.rowDelimiter)
[ 'windows' ] And another repro showing that conversion is not happening: |
This test pass for me: https://runkit.com/ctstone/csv-parse-row-delimiter-error |
About the literal, I was wrong, I'm myself got confused. I believed it was part of a very old version of the parser and the doc was never updated to reflect its removal. |
1.2.1 works for me as well, but is not yet published to NPM Looks like a lot changed from 1.2.0. Guessing it's this line that fixed it. |
Sorry, it should have been published. It is now. |
Repro:
Results in Error:
Invalid closing quote at line 2; found "\r" instead of delimiter "\t"
. I get the the same error if I explicitly setrowDelimiter
to\n
in my options.I would expect the auto-discovery to ignore the first newline it finds (
\n
) since it occurs in a quoted value.The problem goes away when the correct value is explicitly set in options,
{delimiter:'\t', rowDelimiter:'\r\n'}
.The text was updated successfully, but these errors were encountered: