I am trying to read a CSV file in Ruby 1.9.3 (I am not using Rails.)
sessions = CSV.read("c:/scripts/ruby/testcsvencoding.csv", :headers => true,
:encoding => "UTF-8")
sessions.each do | session |
p session['col1'] <-- does not work
p session[0] <--- works
end
The file contains:
col1, col2
a,1
b,2
I saw what seems like "Avoding “Invalid byte sequence in UTF-8″ with Ruby and CSV files", but it may not be the same problem as mine.
When I try the workaround there I get an error.
Is there any way to solve this? Is this a known problem?
This is on Windows