Extract multiple files from gzip in ruby -


actually have multiple .txt files in .gz file. extract .txt files .gz file... example:

gz_extract = zlib::gzipreader.open("sample.gz") gz_extract.each |extract|   print extract end 

the above code prints whatever present in .gz file want un-gzip .txt files. hope ppl understood question....

actually have multiple .txt files in .gz file. extract .txt files .gz file.

gzip cannot contain multiple files together. works 1 file.

if want compress multiple files, first need tar them together, , gzip resulting .tar file, not appear case file using.

if can read contents of sample.gz code provided, further proof have 1 file inside. can try gunzip sample.gz command-line again prove contains 1 file.

edit:

if want code output uncompressed .txt file:

output_file = file.open('sample.txt', 'w')  gz_extract = zlib::gzipreader.open("sample.gz") gz_extract.each_line |extract|   output_file.write(extract) end  output_file.close 

Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -