I need to parse a CSV file that contains the degree symbol (°
) inside a header. If I try to open the file:
CSV.foreach('myfile.csv', headers: true) do |row|
...
end
I get invalid byte sequence in UTF-8 (ArgumentError)
. So I tried few other encodings (ISO-8859-1 and ASCII-8BIT), but I always get a CSV::MalformedCSVError
error.
Which encoding should I specify in order to be able to read the file?
Actually I don't care about the degree symbol, so it works also for me a solution that simply ignores it (and returns for instance 'Tx1 C'
instead of 'Tx1 °C'
).