[MacRuby] #1103: csv.rb oddity

MacRuby ruby-noreply at macosforge.org
Thu Jan 6 14:58:26 PST 2011


#1103: csv.rb oddity
---------------------------------+------------------------------------------
 Reporter:  percent20@…          |       Owner:  lsansonetti@…        
     Type:  defect               |      Status:  new                  
 Priority:  minor                |   Milestone:                       
Component:  MacRuby              |    Keywords:  csv                  
---------------------------------+------------------------------------------
 Copied from mailing list:

 I am not sure if I am just doing something wrong or what, but I am trying
 to read in a CSV file and it seems the code I use for ruby 1.9.2 works
 fine, but not in MacRuby. I think I am doing something wrong, but not
 quite sure what since I am still new to MacRuby and getting familiar with
 it.

 I have put the following code in 'irb' and it works just fine and spits
 out the first part of the array.

 CSV.open('save.csv', 'r') do |row|
     puts row[1]
 end

 With irb I get

 smith
 smith
 smith

 using 'macirb' I get this.

 NoMethodError: undefined method `[]' for #<CSV:0x2005c9a20>
 /Library/Frameworks/MacRuby.framework/Versions/0.8/usr/lib/ruby/1.9.2/csv.rb:1340:in
 `open'

 Same code two different irb's

 My csv file has this in it:

 John,Smith,john at smith.com,1234567
 John,Smith,john at smith.com,1234567
 John,Smith,john at smith.com,1234567

 Can someone point out to me what I am doing wrong?

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1103>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list