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:
        fw.write(line)
    zfile.close()
fw.close()

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
    self._read(readsize)
  File "C:\Python25\lib\gzip.py", line 275, in _read
    self._read_eof()
  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.

Dinesh

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to