当我尝试将 gzip 文件逐行读取到 Ruby 1.8.7 时,它只读取 gzip 压缩文件的第一行。这不会发生在我的测试机器上,只会发生在我的生产服务器上。
它可能与 zlib 或 Gzipreader 有关,但我目前不知道下一步该做什么,任何建议都会很棒。
require 'zlib'
require 'open-uri'
list = Array.new
file = Dir.glob("*").max_by {|f| File.mtime(f)}
File.open(file) do |f|
gz = Zlib::GzipReader.new(f)
#something right here is causing an issue on production system
list = gz.read
gz.close
end
#I need to take the array and push it to redis
list = list.split("\n")
list.shift
list.each do |list|
puts list
puts "\n\n"
end