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

m_ahlenius ahleniusm at
Sun Feb 7 22:51:36 CET 2010


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.



More information about the Python-list mailing list