[Tutor] Reading gzip files

Dinesh B Vadhia dineshbvadhia at hotmail.com
Sun Nov 30 23:51:08 CET 2008

I'm reading gzip files and writing the content out to a text file line by line.  The code is simply:

import gzip
list_zipfiles  = dircache.listdir(zipfolder)
writefile = "out_file.txt"
fw = open(writefile, 'w')

for ziparchive in list_zipfiles:
    zfile = gzip.GzipFile(zipfolder + ziparchive, "r")
    for line in zfile:

The Traceback is:
Traceback (most recent call last):
  File "....py", line 47, in <module>
    for line in zfile:
  File "C:\Python25\lib\gzip.py", line 444, in next
    line = self.readline()
  File "C:\Python25\lib\gzip.py", line 399, in readline
    c = self.read(readsize)
  File "C:\Python25\lib\gzip.py", line 227, in read
  File "C:\Python25\lib\gzip.py", line 275, in _read
  File "C:\Python25\lib\gzip.py", line 311, in _read_eof
    raise IOError, "CRC check failed"
IOError: CRC check failed

I've checked the Python docs and online but cannot find a solution to the problem.  Thanks.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081130/54d114ed/attachment.htm>

More information about the Tutor mailing list