Error using csv.rb - (Errno::ENOENT)

J

Jonathan Kohl

I keep running into this error "(Errno::ENOENT)" when using csv.rb.
I'm not sure what this error means, and I'm wondering if I'm missing
something obvious. This example from p. 241 of _The Ruby Way_ causes
the following output given:
1) a file named data.csv which reads:
"name","age","salary"
"mark",29,34500
"joe",42,32000
"fred",22,22000
"jake",25,24000
"don",32,52000

2) and the Ruby from the example is this:
require 'csv'

IO.foreach("data.csv") {|f| p CSV::parse(f.chomp) }


The output is this:
c:/ruby/lib/ruby/1.8/csv.rb:228:in `initialize': Invalid argument -
"name","age"
,"salary" (Errno::EINVAL)
from c:/ruby/lib/ruby/1.8/csv.rb:228:in `open'
from c:/ruby/lib/ruby/1.8/csv.rb:228:in `open_reader'
from c:/ruby/lib/ruby/1.8/csv.rb:217:in `parse'

Am I missing something obvious? I am using Windows 2000 and Ruby v.
1.8.1-11

Thanks;

-Jonathan
 
R

Ryan Davis

I keep running into this error "(Errno::ENOENT)" when using csv.rb.
I'm not sure what this error means, and I'm wondering if I'm missing
something obvious. This example from p. 241 of _The Ruby Way_ causes
the following output given:
[...]
Am I missing something obvious? I am using Windows 2000 and Ruby v.
1.8.1-11

Nope. Your code works fine for me w/ your data.
504 % ruby -v
ruby 1.8.2 (2005-01-13) [powerpc-darwin7.7.0]

and the library seems pretty stable:
revision 1.10
date: 2004/05/26 14:30:29; author: nahi; state: Exp; lines: +83 -64

BUT... Line 228 for me is not anywhere near initialize (it is in
CSV.parse_row). I'd make sure you aren't seeing some weird version skew
or something worse.
 
J

Jonathan Kohl

Ryan Davis said:
I keep running into this error "(Errno::ENOENT)" when using csv.rb.
I'm not sure what this error means, and I'm wondering if I'm missing
something obvious. This example from p. 241 of _The Ruby Way_ causes
the following output given:
[...]
Am I missing something obvious? I am using Windows 2000 and Ruby v.
1.8.1-11

Nope. Your code works fine for me w/ your data.
504 % ruby -v
ruby 1.8.2 (2005-01-13) [powerpc-darwin7.7.0]

and the library seems pretty stable:
revision 1.10
date: 2004/05/26 14:30:29; author: nahi; state: Exp; lines: +83 -64

BUT... Line 228 for me is not anywhere near initialize (it is in
CSV.parse_row). I'd make sure you aren't seeing some weird version skew
or something worse.

Thanks. The Line 228 thing was really throwing me off as well. I found
that parse_line works:
IO.foreach("data.csv") {|f| p CSV::parse_line(f.chomp) } #used
parse_line instead of parse

Not sure what's up with the previous attempts. I'll try it on another
machine and see what happens.

Thanks;

-Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top