Created
July 30, 2014 13:29
-
-
Save rinaldifonseca/7cf0e83f7803b8b3e8b3 to your computer and use it in GitHub Desktop.
csv-parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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