Hi! I sent the note below earlier and thank-you for the various responses. The program reads a bunch of gzip files, writes the content out to a text file line by line (see code below).
What I'd like to do is ... when an "IOError: CRC check failed" error happens then close the offending file and move on to the next file in the list. How do I achieve this with this particular type of error? Dinesh From: Dinesh B Vadhia Sent: Sunday, November 30, 2008 2:51 PM To: [email protected] Subject: Reading gzip files 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 - [email protected] http://mail.python.org/mailman/listinfo/tutor
