SOLVED
    @transactions = []
    row_number = 0
    @balance = 0
    FasterCSV.foreach("#{RAILS_ROOT}/public/MyExport.csv") do |row|
      transaction = Transaction.new(:effective_date => row[0],
                                   :transaction_type => row[1],
                                   :amount => row[2],
                                   :description => row[4],
                                   :account_type => row[11],
                                   :account_number => row[12],
                                   :account_alias => row[13])
      if row_number > 1
        @balance += transaction[:amount]
        @transactions << transaction
      end
      row_number += 1
    end
biqut2 .. wrote:> I am importing a csv file with the following code. I need to be able to
> load the file into a hash or an array so that I can access the values in
> each column and row individually. There aore 14 columns in each row and
> the number of rows varies from file to file. I have no idea how to do
> this as I am a complete noob to the cvs libray and could only find
> limited documentation. Any help would be greatly appreciated. TIA
> 
> 
>     @transactions = []
>     FasterCSV.foreach("#{RAILS_ROOT}/public/MyExport.csv") do
|row|
>       @transactions << row
>     end
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---