CSV parser fails with mixed quoting and non-standard row_sep
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 218
- Forks
- 135
- Avg merge
- 15h 40m
- Merged PRs (30d)
- 1
Description
opts = {row_sep: "|\n", col_sep: ","}
CSV.parse(CSV.generate(opts) { |csv|
csv << ["yes, it's true"];
csv << [ "CSV is broken"];
csv << ["uhoh!"]; }, opts)
In the example above, the parser will raise a CSV::MalformedCSVError (Unquoted fields do not allow new line <"\n"> in line 2.) error.
It will succeed if any of the following are done:
- pass
force_quotes: truetogenerate - add a comma in each row
- remove the comma from the first row
- use
row_sep: "\n"
Therefore, the problem seems to be that a non-standard row_sep + lines with a field being quoted in one row and unquoted in the next.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with CSV.generate and CSV.parse using row_sep: "|\n", then compare the quoted and unquoted rows against the cases that succeed. Trace how the parser handles row separators and field quoting; done means the mixed-quoting input parses without CSV::MalformedCSVError while the existing alternatives remain valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100