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

Delimiter in content in last column leaves second quote in when parsed

Open CodeProQuo opened this issue 6 years ago • 1 comments

Seems like if there is a delimiter character in the last column of a csv (except for in the last row), then since the field gets wrapped with quotes, when it is parsed the second quote is left in. For example given this input:

first,second,third,fourth
one,aa aa,bb bb,cc cc
two,dd dd,"ee, ee","ff, ff"
three,gg gg,hh hh,"ii, ii"

The parsed data is: [ { first: 'one', second: 'aa aa', third: 'bb bb', fourth: 'cc cc' }, { first: 'two', second: 'dd dd', third: 'ee, ee', fourth: 'ff, ff"' }, { first: 'three', second: 'gg gg', third: 'hh hh', fourth: 'ii, ii' } ]

As you can see "ff, ff" is parsed as 'ff, ff"'. The other values with delimiters in them are parsed fine since they are not in the last row or the last column.

CodeProQuo avatar Nov 25 '19 16:11 CodeProQuo

This is only happening if you specify eol in parameters as \n explicitly.

CodeProQuo avatar Nov 29 '19 16:11 CodeProQuo