jeudi 10 octobre 2019

Reading gz file in Ruby using Zlib. Zlib::GzipReader is reading only the first line of the file and not all lines

I have a gz file that I wanna parse. I am using Zlib::GzipReader library to open it. In console I have the file like this:

164] pry(main)> file
=> #<Zlib::GzipReader:0x00007fadbbfa5a08>
[166] pry(main)> Zlib::GzipReader.open(file.path){|gz| print gz.read }
"Date","Connection type code","Connection id","Currency","Impressions","Campaign","Traffic source","Clicks","Cost (EUR)","Country"
=> nil

Notice that, after reading the file and printing. I just got the first line but in fact, the file contains lots of lines and I wanna have them all

Aucun commentaire:

Enregistrer un commentaire