CSV question

hi,

CSV (more specifically FasterCSV) reads the file i provided row by row

FasterCSV.foreach('path/to/file.csv', 'r') do |r|
r # this is an array of a row in the file
end

but i need to get the array column by column..
is there a way i can simply do this? (even rotating the excel 90 degrees
should do the trick as well!)

FasterCSV.foreachcolumn('path/to/file.csv', 'r') do |c|
c # this is an array of a column yay for all and such things
end

apologize for the redundant question

···

--
Posted via http://www.ruby-forum.com/.

sorry, ignore this post

···

--
Posted via http://www.ruby-forum.com/.

I don't know if there's a better way, but you can do this:

a = FasterCSV.parse(File.read("catalogue.csv"))
a.transpose.each {|column| ...}

but you will have errors if the rows don't have the same number of elements.

Hope this helps,

Jesus.

···

On 10/16/07, Shai Rosenfeld <shaiguitar@gmail.com> wrote:

CSV (more specifically FasterCSV) reads the file i provided row by row

FasterCSV.foreach('path/to/file.csv', 'r') do |r|
r # this is an array of a row in the file
end

but i need to get the array column by column..
is there a way i can simply do this? (even rotating the excel 90 degrees
should do the trick as well!)