Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:141': 0.03; 'skip:p 40': 0.04; 'skip:[ 50': 0.07; 'ioerror:': 0.09; 'exception': 0.12; 'message-----': 0.12; 'am,': 0.13; 'debugging': 0.13; 'wrote:': 0.15; "'rb')": 0.16; 'semanchuk': 0.16; 'unhandled': 0.16; '16,': 0.16; '>>>': 0.16; 'happening': 0.19; 'subject:problem': 0.19; 'to:2**1': 0.21; '(most': 0.21; 'header :In-Reply-To:1': 0.22; 'code': 0.24; 'traceback': 0.25; 'skip:" 30': 0.28; 'script': 0.29; '24,': 0.29; 'problem': 0.29; 'hi,': 0.30; 'subject:': 0.30; 'print': 0.32; 'file.': 0.32; 'error': 0.33; 'list': 0.33; 'sent:': 0.34; 'to:addr:python-list': 0.34; "can't": 0.34; 'last):': 0.35; 'file': 0.36; 'charset:us-ascii': 0.36; 'idea': 0.36; 'from:': 0.36; 'skip:o 20': 0.36; 'friday,': 0.37; 'getting': 0.38; 'subject:: ': 0.38; 'two': 0.38; 'data': 0.39; 'help': 0.39; 'got': 0.39; 'to:addr:python.org': 0.39; 'appreciated.': 0.40; 'skip:z 10': 0.40; 'here:': 0.64; 'zip': 0.65; 'here': 0.66; '"for': 0.67; 'jun': 0.67; 'june': 0.69; 'luck': 0.73; '10:55': 0.84; '11:18': 0.84 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: unzip problem Date: Fri, 24 Jun 2011 13:31:51 -0400 In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: unzip problem Thread-Index: AcwyhjojGsI4L/9qRJuGcw55UHsSmwADehKw References: <9FF28245399DBC4F83C1BB6EA57CA4EC3601@EXCHVS01.ad.sfwmd.gov> From: "Ahmed, Shakir" To: "Philip Semanchuk" , "Lista-Comp-Lang-Python list" X-Virus-Scanned: ClamAV 0.96.1/13237/Fri Jun 24 09:50:33 2011 X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.70 on 141.232.3.26 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 107 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308936713 news.xs4all.nl 182 [::ffff:82.94.164.166]:54225 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8390 -----Original Message----- From: python-list-bounces+shahmed=3Dsfwmd.gov@python.org [mailto:python-list-bounces+shahmed=3Dsfwmd.gov@python.org] On Behalf Of Philip Semanchuk Sent: Friday, June 24, 2011 11:18 AM To: Lista-Comp-Lang-Python list Subject: Re: unzip problem On Jun 24, 2011, at 10:55 AM, Ahmed, Shakir wrote: > Hi, >=20 >=20 >=20 > I am getting following error message while unziping a .zip file. Any > help or idea is highly appreciated. >=20 >=20 >=20 > Error message>>> >=20 > Traceback (most recent call last): >=20 > File "C:\Zip_Process\py\test2_new.py", line 15, in >=20 > outfile.write(z.read(name)) >=20 > IOError: (22, 'Invalid argument') Start debugging with these two steps -- 1) Add this just after "for name in z.namelist():" print name That way you can tell which file is failing. 2) You can't tell whether you're getting an error on the write or the read because you've got two statements combined into one line. Change this -- outfile.write(z.read(name)) to this -- data =3D z.read(name) outfile.write(data) Good luck Philip >=20 >=20 >=20 >=20 >=20 > The script is here: >=20 > ***************************** >=20 > fh =3D open('T:\\test\\*.zip', 'rb') >=20 > z =3D zipfile.ZipFile(fh) >=20 > for name in z.namelist(): >=20 > outfile =3D open(name, 'wb') >=20 >=20 >=20 > outfile.write(z.read(name)) >=20 > print z >=20 > print outfile >=20 > outfile.close() >=20 >=20 >=20 > fh.close() >=20 > ******************************** The problem found in outfile.Write. The error code is here and is happening when few of the files are already unzipped from the zip file >>> T:\applications\tst\py\Zip_Process >>> drg100.aux >>> >>> >>> drg100.fgdc.htm >>> >>> >>> drg100.htm >>> >>> >>> drg100.sdw >>> >>> >>> drg100.sid >>> Unhandled exception while debugging... Traceback (most recent call last): File "C:\Zip_Process\py\test2_new.py", line 16, in outfile.write(data) IOError: (22, 'Invalid argument')