Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: James Gray
RE: Get 'nil' when use :headers => true option [ reply ]  
2008-07-14 12:56
Once headers are activated, FasterCSV no longer returns Arrays. Instead it returns FasterCSV::Row objects.

You could get your example to work with something like:

type, time, payee amount = row.fields

Must better thought would be to just use the headers. That's why you told FasterCSV to read them after all.

puts row["payee"] # or whatever the column name is

Hope that helps.

James Edward Gray II

By: D C
Get 'nil' when use :headers => true option [ reply ]  
2008-07-11 18:27
The following works ok...
FasterCSV.foreach("transactions.csv", :headers => false) do |row|
type, time, payee, amount = row
puts payee
end

This does not, all variables are nil...
FasterCSV.foreach("transactions.csv", :headers => true) do |row|
type, time, payee, amount = row
puts payee
end

It does not matter if :return_headers is true or false.

Any ideas?