Projects

Ticket #125 (closed defect: fixed)

Opened 18 months ago

Last modified 7 months ago

Problem with CSV library

Reported by: deepak.gulati@… Owned by: lsansonetti@…
Priority: major Milestone: MacRuby 0.5
Component: MacRuby Keywords: CSV
Cc:

Description

Here is a simple program that reads a CSV files and prints the various "fields" in it:

require 'CSV' CSV.foreach("books.csv", headers: true) do |row|

puts "#{rowName?}, #{rowPrice?}"

end

With Ruby 1.9.0 (2008-07-25 revision 18217), it runs fine, but with macruby, I get the following error:

/Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/CSV.rb:1471:in `each': no block given (yield) (LocalJumpError)

from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/CSV.rb:1021:in `block in foreach' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/CSV.rb:1193:in `open' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/CSV.rb:1020:in `foreach' from csvtest.rb:2:in `foreach:headers:' from csvtest.rb:2:in `<main>'

Is the CSV library included with macruby, incompatible with ruby 1.9?

p.s. "books.csv" looks like this: Name,Price Gone with the wind,100.12 Who stole my cheese,104.22 Cocoa Programming with Aaron Hillegasse,42.31

I am attaching both the program and CSV file because the code doesn't look like in the ticket's preview.

Attachments

csvtest.rb Download (108 bytes) - added by deepak.gulati@… 18 months ago.
books.csv Download (110 bytes) - added by deepak.gulati@… 18 months ago.

Change History

Changed 18 months ago by deepak.gulati@…

Changed 18 months ago by deepak.gulati@…

Changed 7 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from MacRuby 0.4 to MacRuby 0.5

As of trunk r2432, this should work.

$ ./miniruby  t.rb 
Gone with the wind, 100.12
Who stole my cheese, 104.22
Cocoa Programming with Aaron Hillegasse, 42.31
Note: See TracTickets for help on using tickets.