unzip problem

Philip Semanchuk philip at semanchuk.com
Fri Jun 24 11:18:04 EDT 2011


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()
> 
> ********************************
> 
> 
> 
> <winmail.dat>-- 
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list