Ruby 1.9.2 - Read and parse a remote CSV

≡放荡痞女 提交于 2019-11-30 11:14:55
Steve Wilhelm

On Mac OS X 10.6.7, using ruby r1.9.2, I get the same error as displayed above. But using the following code to read CSV files works for the example URL provided:

require 'rubygems'
require 'open-uri'
require 'csv'

def read(url)
 CSV.new(open(url), :headers => :first_row).each do |line|
   puts line
   puts line[0]
   puts line['FEB11']
 end
end

read("http://www.euribor-ebf.eu/assets/modules/rateisblue/processed_files/myav_EURIBOR_2011.csv")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!