Skip to content

Instantly share code, notes, and snippets.

@doyle
Created January 2, 2018 14:25
Show Gist options
  • Save doyle/45b3d6a0476ad7782b6870485b0d62a5 to your computer and use it in GitHub Desktop.
Save doyle/45b3d6a0476ad7782b6870485b0d62a5 to your computer and use it in GitHub Desktop.
Converts a csv file in the windows utf 8 encoding to utf 8
require 'csv'
file = ARGV[0]
rows = CSV.read(file, :encoding => 'windows-1251:utf-8')
out = CSV.open("#{file.split('.')[0]}_fixed.csv", 'wb')
rows.each{|row| out << row}
out.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment