从url导入CSV Errno :: ENAMETOOLONG:文件名太长 [英] Import CSV from url Errno::ENAMETOOLONG: file name too long
本文介绍了从url导入CSV Errno :: ENAMETOOLONG:文件名太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试从网址导入CSV文件,但我得到 Errno :: ENAMETOOLONG:文件名太长
。我处理的文件如下:
I'm trying to import a CSV file from a url but i'm getting Errno::ENAMETOOLONG: file name too long
. I process the file as follow:
require 'open-uri'
url = "http://de65.grepolis.com/data/csv.txt"
url_data = open(url).read()
SmarterCSV.process(url_data, {
...
})
我失踪了什么?
推荐答案
您必须传递一个应该在服务器上的文件名。现在你正在传递所有数据。做这样的事情
You have to pass a filename which should be on server. rightnow you are passing all data . Do something like this
require 'open-uri'
url = "http://de65.grepolis.com/data/csv.txt"
url_data = open(url).read()
File.open('/tmp/file_name', 'w') { |file| file.write(url_data) }
SmarterCSV.process('/tmp/file_name',{ })
这篇关于从url导入CSV Errno :: ENAMETOOLONG:文件名太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文