ruby - Compressing using Bzip2 on-the-fly to a file? -
is a program that generates large CSV files, for example: arr = (0 .. 10) .to_a CSV.open ("foo.csv", "wb"). Csv | (2 ** 16). Times {csv & lt; & Lt; Arr} This will generate a large file, so I want to compress on-flyer , and instead, Compressed CSV file ( foo.csv ) outputs output to a Bizip-compressed CSV file ( foo.csv.bzip ). I have an example of "Ruby-BGIP 2" gem: writer = BGP :: author. new file. Open ('file') author & lt; & Lt; 'Data 1' author.code I'm not sure how to write BGP2 from CSV one. You can also create an CSV object with IO or IO Something like enough, such as Bzip2 :: Writer . For example file.open ('file.bz2', 'wb'). F | Author = Bugz :: Author. The new CSV (author) does. CSV | (2 ** 16). Times {csv & lt; & Lt; Arr} End Writer. Closing