简体   繁体   中英

How to process bigger gzipped files with Ruby 1.8

是否可以使用有限的RAM使用纯Ruby(1.8)处理巨大的文件(〜3G)?

是的,您可以使用Zlib :: GzipReader通过#each_line或#each_byte逐行处理它。

I guess the following would make sense:

 Zlib::GzipReader.open(file) { |gz|
   gz.each_line { |line|
     #do stuff
   }
   gz.close
 }

Let me know if you have a better solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM