[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Error using csv.rb - (Errno::ENOENT

kohljonathan

4/5/2005 9:44:00 PM

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
2 Answers

Ryan Davis

4/5/2005 10:49:00 PM

0


On Apr 5, 2005, at 2:44 PM, Jonathan Kohl wrote:

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

--
ryand-ruby@zenspider.com - Seattle.rb -
http://www.zenspider.com/...
http://blog.zens... - http://rubyforge.org/proje...



kohljonathan

4/6/2005 3:15:00 AM

0

Ryan Davis <ryand-ruby@zenspider.com> wrote in message news:<49943fb9252d2a0dfae8d0653965c648@zenspider.com>...
> On Apr 5, 2005, at 2:44 PM, Jonathan Kohl wrote:
>
> > 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