Skip to content

Instantly share code, notes, and snippets.

@ruckus
Created October 17, 2011 20:55
Show Gist options
  • Select an option

  • Save ruckus/1293773 to your computer and use it in GitHub Desktop.

Select an option

Save ruckus/1293773 to your computer and use it in GitHub Desktop.
require 'csv'
require 'iconv'
iconv = Iconv.new("UTF-16//TRANSLIT//IGNORE", "UTF-8")
CSV.open("/path/to/data.csv", "wb") do |csv|
csv << ["WineID", "Wine", "Year", "Producer"]
rows.each do |row|
data = [ row[0] ]
data << (row[1] ? iconv.iconv(row[1]) : "")
data << (row[2] ? iconv.iconv(row[2]) : "")
data << (row[3] ? iconv.iconv(row[3]) : "")
csv << data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment