Eric Luo wrote:
> Why 'a,"bc"d' could not be parsed correctly in both FasterCSV and CSV
> libary. while
> "a,'bc'd" could be parsed into [["a", "'bc'd"]] successfully.
> --------------------------------------------------------------------------
> irb(main):001:0> require 'fastercsv'
> true
> irb(main):002:0> FasterCSV.parse("a,'bc'd")
> [["a", "'bc'd"]]
> irb(main):003:0> FasterCSV.parse('a,"bc"d')
> FasterCSV::MalformedCSVError: Unclosed quoted field on line 1.

Here are the rules:
1) Commas (,) separate fields. (You can pick a different delimiter if
you like.)
2) Double-quotes (") are used to quote fields. They must surround the
entire field.
3) Double-quotes (") are used to escape double-quotes inside a field.

If you want to write ['a', '"bc"d'] as CSV, do this:
a,"""bc""d"

Cheers,
Dave