开发者

How to process bigger gzipped files with Ruby 1.8

开发者 https://www.devze.com 2023-03-30 00:31 出处:网络
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.

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

精彩评论

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