Skip to content

Instantly share code, notes, and snippets.

@rinaldifonseca
Created July 30, 2014 13:29
Show Gist options
  • Save rinaldifonseca/7cf0e83f7803b8b3e8b3 to your computer and use it in GitHub Desktop.
Save rinaldifonseca/7cf0e83f7803b8b3e8b3 to your computer and use it in GitHub Desktop.
csv-parser
require 'rubygems'
require 'open-uri'
require 'csv'
#remote
def read(url)
CSV.new(open(url), :headers => :first_row).each do |line|
puts line
puts line[0].force_encoding('iso-8859-1').encode('utf-8')
puts line['FEB11']
end
end
read("http://www.site.com/meu.csv")
CSV.foreach("/tmp/meu.csv", encoding: "iso-8859-1:UTF-8") do |r|
puts r[0]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment