mafintosh / csv-parser

Streaming csv parser inspired by binary-csv that aims to be faster than everyone else
MIT License
1.41k stars 134 forks source link

Error handling #205

Open edencorbin opened 2 years ago

edencorbin commented 2 years ago

Feature Proposal

As far as I know if csv-parser encounters an error it silently stops on that row, while parsing all the previouse lines. Not knowing this I got far into a project and realized not all my rows were returning by reviewing the row count. I propose an on('error') method so that we can be aware of and handle these errors. After removing the problem line my whole CSV would parse.

Feature Use Case

Better error feedback and no swallowing of errors.

chr4ss12 commented 2 years ago

I would also add that some kind of detection of the BOM would have been good / automatic handling of it, I spent 3 hrs on debugging why the CSV parser shows me that I have csv record of

{ "Content id": "TEMPTEST" },

but when doing csv['Content id'] it results undefined, (because the key 'Content id' actually contains BOM as well, so the BOM is parsed as part of the first CSV field)

it would be good to throw error on that case, as having CSV files with bom is quite frequent occurence from excel exported files, and this library does not work with these files.

https://github.com/mafintosh/csv-parser/issues/196