From: Gavin Sinclair Date: 2004-06-14T10:07:20+09:00 Subject: Re: How to read a .csv file into a 2D array? On Monday, June 14, 2004, 9:43:38 AM, Todd wrote: > How can I do this more elegantly? I'm not sure what you're trying to achieve. > ary = [] > fi = File.open("test1.csv","r") > fo = File.open("test1.out","w") > fi.each { |line| > a = line.strip.split(',') > ary << a > fo.puts line > } That's just copying fi to fo with no transformation. > #~ # test print-out of one arrayrow > i=0 > 1.times do > puts ary[i] > i+=1 > end *1* times do something? That must be a mistake. > fi.close > fo.close What you're actually *doing* (i.e. creating a 2D array) looks fine. The rest of the stuff seems meaningless. Cheers, Gavin