davidsantiago / clojure-csv

A library for reading and writing CSV files from Clojure
187 stars 35 forks source link

More relaxed `quote-char` parsing with `strict = false` #37

Open i0cus opened 7 years ago

i0cus commented 7 years ago

Hi David,

I've recently faced issues with Google Docs exported sheet, since (of course) it does not escape quotes. The issue happens if field starts with quoted value, but then continues unquoted. Minimal reproduction case would be:

Lewis;Huey;"Hip To Be Square" by Huey Lewis and the News

It chokes on the \space right after second quote. I'd expect it to thrown an exception with strict = true, but with strict = false I'd like it to recover into:

["Lewis", "Huey", "\"Hip To Be Square\" by Huey Lewis and the News"]

I did manage to prototype a fix within parse-csv-line to achieve this, it would however affect quoting related change done in 2.0.2 -- as it modifies default behavior (with strict = false). Strict mode still fails as expected. Related 2.0.2 quoting tests are currently a regression and would have to be moved to strictness tests section.

Would you be interested?

i0cus commented 7 years ago

Minimal git diff (with mentioned tests still failing): diff.txt