From: James Edward Gray II Date: 2006-03-29T01:04:07+09:00 Subject: Re: Chaning the quote-character in csv parsing On Mar 28, 2006, at 8:03 AM, Jens Auer wrote: > I have a bunch of files containing lines as comma-seperated values. > Unfortunately, the character used for quoting is a single quote (') > and not the double quote ("). How can I tell the csv library (or > fastercsv or any other csv-parsing library) which character is used > for quoting? I'm not aware of a way to change it for either library, sadly. If your data is simple, you might get away with manipulating it into shape: >> require "csv" => true >> line = "one,'quoted','quoted, but with comma'" => "one,'quoted','quoted, but with comma'" >> CSV.parse_line(line.tr("'", '"')) => ["one", "quoted", "quoted, but with comma"] Unfortunately, on of the examples you showed is more complicated than that: >> line = 'some words "some quoted text" some more words' => "some words \"some quoted text\" some more words" >> CSV.parse_line('"' + line.gsub('"', '""').tr("'", '"') + '"') => ["some words \"some quoted text\" some more words"] Those transforms need to be done on a field by field basis though, to correctly convert data like that. Hope that helps. James Edward Gray II