Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8390 > unrolled thread

RE: unzip problem

Started by"Ahmed, Shakir" <shahmed@sfwmd.gov>
First post2011-06-24 13:31 -0400
Last post2011-06-24 13:31 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  RE: unzip problem "Ahmed, Shakir" <shahmed@sfwmd.gov> - 2011-06-24 13:31 -0400

#8390 — RE: unzip problem

From"Ahmed, Shakir" <shahmed@sfwmd.gov>
Date2011-06-24 13:31 -0400
SubjectRE: unzip problem
Message-ID<mailman.374.1308936713.1164.python-list@python.org>

-----Original Message-----
From: python-list-bounces+shahmed=sfwmd.gov@python.org
[mailto:python-list-bounces+shahmed=sfwmd.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,
> 
> 
> 
> I am getting following error message while unziping a .zip file. Any
> help or idea is highly appreciated.
> 
> 
> 
> Error message>>>
> 
> Traceback (most recent call last):
> 
>  File "C:\Zip_Process\py\test2_new.py", line 15, in <module>
> 
>    outfile.write(z.read(name))
> 
> 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 = z.read(name)
   outfile.write(data)


Good luck
Philip

> 
> 
> 
> 
> 
> The script is here:
> 
> *****************************
> 
> fh = open('T:\\test\\*.zip', 'rb')
> 
> z = zipfile.ZipFile(fh)
> 
> for name in z.namelist():
> 
>    outfile = open(name, 'wb')
> 
> 
> 
>    outfile.write(z.read(name))
> 
>    print z
> 
>    print outfile
> 
>    outfile.close()
> 
> 
> 
> fh.close()
> 
> ********************************


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
>>> <zipfile.ZipFile instance at 0x00E2F648>
>>> <open file 'drg100.aux', mode 'wb' at 0x00E12608>
>>> drg100.fgdc.htm
>>> <zipfile.ZipFile instance at 0x00E2F648>
>>> <open file 'drg100.fgdc.htm', mode 'wb' at 0x00E128D8>
>>> drg100.htm
>>> <zipfile.ZipFile instance at 0x00E2F648>
>>> <open file 'drg100.htm', mode 'wb' at 0x00E12608>
>>> drg100.sdw
>>> <zipfile.ZipFile instance at 0x00E2F648>
>>> <open file 'drg100.sdw', mode 'wb' at 0x00E128D8>
>>> drg100.sid
>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "C:\Zip_Process\py\test2_new.py", line 16, in <module>
    outfile.write(data)
IOError: (22, 'Invalid argument')

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web