From: Eric Luo Date: 2006-05-09T17:16:46+09:00 Subject: Re: Q about the FasterCSV ------=_Part_7803_13091842.1147162603407 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thanks for your patient and time, Dave Finally I understand the rules of the CSV format by your clear explanatioon= . I really appreciate your help On 5/9/06, Dave Burt wrote: > > 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 > > ------=_Part_7803_13091842.1147162603407--