<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=Windows-1252>
<META content="MSHTML 6.00.6000.16735" name=GENERATOR></HEAD>
<BODY id=MailContainerBody
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px"
bgColor=#ffffff leftMargin=0 topMargin=0 CanvasTabStop="true"
name="Compose message area">
<DIV><FONT face=Garamond color=#000080></FONT></DIV>
<DIV><FONT face=Garamond color=#000080>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).</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080>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?</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080>Dinesh</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><BR></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=dineshbvadhia@hotmail.com
href="mailto:dineshbvadhia@hotmail.com">Dinesh B Vadhia</A> </DIV>
<DIV><B>Sent:</B> Sunday, November 30, 2008 2:51 PM</DIV>
<DIV><B>To:</B> <A title=tutor@python.org
href="mailto:tutor@python.org">tutor@python.org</A> </DIV>
<DIV><B>Subject:</B> Reading gzip files</DIV></DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=Garamond color=#000080>I'm reading gzip files and writing the
content out to a text file line by line. The code is simply:</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080>import gzip</FONT></DIV>
<DIV><FONT face=Garamond color=#000080>list_zipfiles =
dircache.listdir(zipfolder)<BR></FONT><FONT face=Garamond
color=#000080>writefile = "out_file.txt"<BR>fw = open(writefile,
'w')</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080>for ziparchive in
list_zipfiles:<BR> zfile = gzip.GzipFile(zipfolder +
ziparchive, "r")</FONT></DIV>
<DIV><FONT face=Garamond color=#000080> </FONT><FONT
face=Garamond color=#000080>for line in zfile:</FONT></DIV>
<DIV><FONT face=Garamond
color=#000080> fw.write(line)</FONT></DIV>
<DIV><FONT face=Garamond
color=#000080> zfile.close()</FONT></DIV>
<DIV><FONT face=Garamond color=#000080>fw.close()</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080>The Traceback is:</FONT></DIV>
<DIV><FONT face=Garamond color=#000080>Traceback (most recent call
last):<BR> File "....py", line 47, in <module><BR>
for line in zfile:<BR> File "C:\Python25\lib\gzip.py", line 444, in
next<BR> line = self.readline()<BR> File
"C:\Python25\lib\gzip.py", line 399, in readline<BR> c =
self.read(readsize)<BR> File "C:\Python25\lib\gzip.py", line 227, in
read<BR> self._read(readsize)<BR> File
"C:\Python25\lib\gzip.py", line 275, in _read<BR>
self._read_eof()<BR> File "C:\Python25\lib\gzip.py", line 311, in
_read_eof<BR> raise IOError, "CRC check failed"<BR>IOError:
CRC check failed</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080>I've checked the Python docs and online
but cannot find a solution to the problem. Thanks.</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV>
<DIV><FONT face=Garamond color=#000080>Dinesh</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Garamond color=#000080></FONT> </DIV></BODY></HTML>