开发者

How to process bigger gzipped files with Ruby 1.8

Is it possible to process a huge (~3G) file with pure Ruby (1.8) using limit开发者_JAVA技巧ed amount of RAM?


Yes, you can use Zlib::GzipReader to process it line by line using #each_line or #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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜