Forum: Ruby Q about the FasterCSV

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eric L. (Guest)
on 2006-04-27 07:40
(Received via mailing list)

I have a csv file, which has the following data, for example:
line 1, "1"
line 2, "2"

And I use the following code snippet to parse this file,

require 'fastercsv'"test.csv")

unfortunately, It failed and complained that:

FasterCSV::MalformedCSVError: Unclosed quoted field on line 1.

I'm wondering what the real problem is,

Do I really need to escape the double quote before pass the file to
Logan C. (Guest)
on 2006-04-27 08:05
(Received via mailing list)
On Apr 26, 2006, at 11:38 PM, Eric L. wrote:

> require 'fastercsv'

Remember its "comma-separated", fiddling around I discovered that

line 1,"1"
line 2,"2"

Works absolutely fine. I'm not CSV guru so I don't know if FasterCSV
has a bug or if your CSV is malformed.
Eric L. (Guest)
on 2006-04-27 09:50
(Received via mailing list)
I did check this problem out finally:

In the csv file,
line 1,"1"
line 2,  "2"

the line 1 could be parsed successfully, but the line 2 will failed.
The only difference between the two lines is that there is a space char
between the comma char and the double quote char in line 2, while line 1

I suspect that space char between the comma char(,) and the double quote
char(") make the faster csv parser to take the space char as part of the
second field. And then the double quote should be escaped, but it

Is it a bug or expected?
This topic is locked and can not be replied to.