# Q about the FasterCSV

**URL:** <https://www.ruby-forum.com/t/q-about-the-fastercsv/58921>\
**Category:** Ruby\
**Created:** [April 27, 2006, 5:40am UTC](https://www.ruby-forum.com/t/q-about-the-fastercsv/58921 "2006-04-27T05:40:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [April 27, 2006, 5:40am UTC](https://www.ruby-forum.com/t/q-about-the-fastercsv/58921/1 "2006-04-27T05:40:46Z")

</div>

Hi,

## I have a csv file, which has the following data, for example: test.csv

line 1, “1”  
line 2, “2”

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

require ‘fastercsv’  
FasterCSV.read(“test.csv”)

unfortunately, It failed and complained that:

FasterCSV::MalformedCSVError: Unclosed quoted field on line 1.  
e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-0.2.0/lib/faster\_csv.rb:1165:in  
`shift' e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-0.2.0/lib/faster_csv.rb:1090:in`shift’  
e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-0.2.0/lib/faster\_csv.rb:1040:in  
`each' e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-0.2.0/lib/faster_csv.rb:1051:in`read’  
e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-0.2.0/lib/faster\_csv.rb:840:in  
`read' e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-0.2.0/lib/faster_csv.rb:790:in`open’  
e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-0.2.0/lib/faster\_csv.rb:840:in  
`read’

I’m wondering what the real problem is,

Do I really need to escape the double quote before pass the file to  
read?

---

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [April 27, 2006, 6:05am UTC](https://www.ruby-forum.com/t/q-about-the-fastercsv/58921/2 "2006-04-27T06:05:30Z")

</div>

On Apr 26, 2006, at 11:38 PM, Eric L. wrote:

> require ‘fastercsv’  
> FasterCSV.read(“test.csv”)

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.

---

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [April 27, 2006, 7:50am UTC](https://www.ruby-forum.com/t/q-about-the-fastercsv/58921/3 "2006-04-27T07:50:43Z")

</div>

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  
not.

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  
hadn’t.

Is it a bug or expected?
