YS-L / csvlens

Command line csv viewer
MIT License
2.49k stars 40 forks source link

RFC4180 column with double quotes as escape character having a comma will crash csvlens #13

Closed mroxh closed 1 year ago

mroxh commented 1 year ago

HI,

I found this interesting viewer and I was testing. csvlens crashes when the csv has columns with double quotes as escape characters including a comma.

See also RFC 4180, e.g. https://www.loc.gov/preservation/digital/formats/fdd/fdd000323.shtml where it is defined that csv file can have comma, cr, lf, or double quote in the data, but are escaped by double quotes.

Try this csv: Column1, "column2"
1, "quote"
5, "Comma, comma"

It would also be nice, if the double quotes are removed/not displayed, as these are escape characters.

YS-L commented 1 year ago

Hello! Escaping using double quotes is supported. The issue here is that you cannot have spaces between commas and quotes - the underlying csv crate considers it as malformed CSV data. See this related issue: https://github.com/BurntSushi/rust-csv/issues/181

Though, csvlens could have exited more gracefully in this case.