Ruby/Rails CSV parsing, invalid byte sequence in UTF-8

前端 未结 7 1756
别跟我提以往
别跟我提以往 2020-12-24 01:02

I am trying to parse a CSV file generated from an Excel spreadsheet.

Here is my code

require \'csv\'
file = File.open(\"input_file\")
csv = CSV.parse         


        
7条回答
  •  难免孤独
    2020-12-24 01:21

    I had this same problem and was just using google spreadsheets and then downloading as a CSV. That was the easiest solution.

    Then I came across this gem

    https://github.com/singlebrook/utf8-cleaner

    Now I don't need to worry about this issue at all. Hope this helps!

提交回复
热议问题