<!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!&nbsp; I sent the note below earlier 
and thank-you for the various responses.&nbsp; 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>&nbsp;</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.&nbsp; How do I achieve this with this 
particular type of error?</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080>Dinesh</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</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.&nbsp; The code is simply:</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080>import gzip</FONT></DIV>
<DIV><FONT face=Garamond color=#000080>list_zipfiles&nbsp; = 
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>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080>for ziparchive in 
list_zipfiles:<BR>&nbsp;&nbsp;&nbsp;&nbsp;zfile = gzip.GzipFile(zipfolder + 
ziparchive, "r")</FONT></DIV>
<DIV><FONT face=Garamond color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT 
face=Garamond color=#000080>for line in zfile:</FONT></DIV>
<DIV><FONT face=Garamond 
color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fw.write(line)</FONT></DIV>
<DIV><FONT face=Garamond 
color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;zfile.close()</FONT></DIV>
<DIV><FONT face=Garamond color=#000080>fw.close()</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080>The Traceback is:</FONT></DIV>
<DIV><FONT face=Garamond color=#000080>Traceback (most recent call 
last):<BR>&nbsp; File "....py", line 47, in &lt;module&gt;<BR>&nbsp;&nbsp;&nbsp; 
for line in zfile:<BR>&nbsp; File "C:\Python25\lib\gzip.py", line 444, in 
next<BR>&nbsp;&nbsp;&nbsp; line = self.readline()<BR>&nbsp; File 
"C:\Python25\lib\gzip.py", line 399, in readline<BR>&nbsp;&nbsp;&nbsp; c = 
self.read(readsize)<BR>&nbsp; File "C:\Python25\lib\gzip.py", line 227, in 
read<BR>&nbsp;&nbsp;&nbsp; self._read(readsize)<BR>&nbsp; File 
"C:\Python25\lib\gzip.py", line 275, in _read<BR>&nbsp;&nbsp;&nbsp; 
self._read_eof()<BR>&nbsp; File "C:\Python25\lib\gzip.py", line 311, in 
_read_eof<BR>&nbsp;&nbsp;&nbsp; raise IOError, "CRC check failed"<BR>IOError: 
CRC check failed</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080>I've checked the Python docs and online 
but cannot find a solution to the problem.&nbsp; Thanks.</FONT></DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080>Dinesh</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Garamond color=#000080></FONT>&nbsp;</DIV></BODY></HTML>