Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个每隔几个小时更新一次的远程 CSV,它有 1m+ 行,我正在尝试确定是否可以逐行下载文件并解析它(我只对前 500,000 行感兴趣)而不是而不是必须下载整个文件然后处理它。
你可以试试这样的...
require 'csv' require 'open-uri' def read(url) open(url) do |f| f.each_line do |l| CSV.parse(l) do |row| p [row] end end end end