csvToJson icon indicating copy to clipboard operation
csvToJson copied to clipboard

Bug ; in ""

Open guilhermeagirardi opened this issue 3 years ago • 4 comments

Hi guys!

I found a possible bug. I'm importing a file with approximately 3000 lines, and strangely the result was not interpreted as expected. "Just like Excel", for example.

Debugging, I realized that csvToJson splits columns that are not meant to split. Example: ABC test1;"test2;...";test3

In the case above, if I open it in Excel, I get the correct result: image

In csvToJson, it interprets as 4 columns instead of 3. It splits ; even if you are inside "". I believe that the correct behavior would be to ignore these cases, because in my understanding the user wants to inform that it is text;

guilhermeagirardi avatar Jun 22 '21 13:06 guilhermeagirardi

Ps.: I know I could use it for SubArray, but I don't want it to return in an array, but in a normal string.

guilhermeagirardi avatar Jun 22 '21 13:06 guilhermeagirardi

Hi @guilhermeagirardi

I understand your problem, but it is not so easy to implement what do you want. A possible solution is to use another field delimiter (see Field Delimiter). Obviously the field delimiter must not be included in the text. Please let me know if this solution works for you.

iuccio avatar Jun 23 '21 18:06 iuccio

Hey guys! Additionally it breaks on new lines withing qotes so if text contains multilines it interprets it as a new row

usulpro avatar Jul 22 '21 08:07 usulpro

I ran into the same problem. For others, this package seems to handled these cases well https://www.npmjs.com/package/csvtojson

jfloodnet avatar Nov 25 '21 05:11 jfloodnet

Same problem here. The delimeter splits the input-csv incorrectly, as it does not take care of whether values have been wrapped in a quote. This bug makes the package basically useless for large datasets.

Suggested solution for the developer: Instead of using regular .split-method, apply a RegEx that will split the input-string only if the delimeter is not wrapped in a " or '

FlxAlbroscheit avatar Oct 01 '22 11:10 FlxAlbroscheit

@FlxAlbroscheit can you upload a data example that you are using?

As i suggested in https://github.com/iuccio/csvToJson/issues/23#issuecomment-867072236 you can change the field delimiter!

What it means:

This bug makes the package basically useless for large datasets.?

iuccio avatar Oct 09 '22 12:10 iuccio