csvToJson
csvToJson copied to clipboard
Bug ; in ""
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:
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;
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.
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.
Hey guys! Additionally it breaks on new lines withing qotes so if text contains multilines it interprets it as a new row
I ran into the same problem. For others, this package seems to handled these cases well https://www.npmjs.com/package/csvtojson
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 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.?