Jesús Gabriel y Galán
10/16/2007 2:35:00 PM
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!)
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.