question on using tarfile to read a *.tar.gzip file

m_ahlenius ahleniusm at gmail.com
Sun Feb 7 16:51:36 EST 2010


Hi,

I have a number of relatively large number *tar.gzip files to
process.  With the py module tarfile, I see that I can access and
extract them, one at a time to a temporary dir, but that of course
takes time.

All that I need to do is to read the first and last lines of each file
and then move on to the next one.  I am not changing anything in these
files - just reading.  The file lines are not fixed lengths either,
which makes it a bit more fun.

Is there a way to do this, without decompressing each file to a temp
dir?  Like is there a method using some tarfile interface adapter to
read a compressed file?  Otherwise I'll just access each file, extract
it,  grab the 1st and last lines and then delete the temp file.

thx

'mark



More information about the Python-list mailing list