I'm using CSV class to read a csv file with Ruby.
Here is my code
CSV.foreach('../../../db/data/xxxx.csv') do |row|
# ...
row[0].to_i
# ...
end
File '../../../db/data/xxxx.csv' surely exists. row[0] returns "1".
So I expect row[0].to_i to return 1, but row[0].to_i returns 0. I thought it is encoding matter of row[0].encoding, but it returns #<Encoding:UTF-8>.
row[0]
#=> "1"
row[0].class
#=> String
row[0].encoding
#=> Encoding:UTF-8
row[0] == "1"
#=> false
Does anyone help me?