Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Info regarding Zlib::GzipReader

Thread Tools

Info regarding Zlib::GzipReader

J-H Johansen
Posts: n/a

I'm trying to parse through a gzip'ed proxy access log with
Zlib::GzipReader and I'm having some difficulties.

f =, "r")
gz =
gz.readlines.each do |block|
puts block

What this piece of code will do is to read the first 6 lines of the
proxy log before it reaches (what it believes to be) the end of the
file. These few lines happens to be the info header which contains:

#Software: ......
#Version: ......
#Start-date: ......
#Date: ......
#Fields: ....................
#Remark: ........

The access log contains a wee bit more than that though (980796 lines).
By just using it seems I can read the whole file.

I'm speculating here but I think that maybe the gzip file may have
been buffered. I.e. first 6 lines has been gzip'ed and then the rest
of the file has been gzip'ed and appended to it afterwards.

One way of fixing the problem is to gunzip the file and then gzip the
output into a new file. Problem solved (sort of).

Do any of you know of any other way to do this without actually
modifying the access logs ?

I'm thinking of something along the lines of breaking up the file into
smaller file handles which in turn can be used by GzipReader, but I
don't know how this is done.

Anyone know how this can be done or if there is any better ways of doing it ?


Jens-H Johansen
There are 10 kinds of people in the world: Those who understand binary and
those who don't...

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Info needed regarding iostreams C++ 6 05-08-2006 12:26 PM
Question Regarding Cisco AS5300 (See Info Bellow) Sandra@ C.D.R. Cisco 1 04-28-2004 05:05 PM
info regarding digital low pass fir filter design in VHDL... dhaanya nair VHDL 0 02-26-2004 08:36 AM
Info Regarding Struts DhirenThakur Java 2 10-17-2003 02:37 PM
Nasty bug in documentation regarding globalization - wrong Culture Info name for Serbian (Cyrilic) Dejan Vesic ASP .Net 1 07-03-2003 12:32 AM