node-csvtojson icon indicating copy to clipboard operation
node-csvtojson copied to clipboard

Fix bug where closing quote was not removed

Open tec opened this issue 1 year ago • 0 comments

I have seen many (manually edited) csv files in the wild that are formatted to visually have commas like columns. Example:

title ,description                                 ,number value,    more text,number 2
line 1,"short, precise"                            ,5           ,    sometimes,1
line 2,"a long, long description"                  ,6           ,         even,2
line 3,"an even longer description with many words",5           ,right-aligned,3
line 4,         "     and crazy stuff     "        ,5           ,      columns,3

The current implementation has some errors with those lines.

This closing quote and the whitespace is not removed (only the last space to be precise):

line 1,"short, precise"                            ,5           ,    sometimes,1
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This whitespace is not removed even if option trim is enabled (neither is the closing quote)

line 4,         "     and crazy stuff     "        ,5           ,      columns,3
                 ^^^^^               ^^^^^

The pull requests fixes those issues

tec avatar Mar 10 '23 16:03 tec