unzip problem

Ahmed, Shakir shahmed at sfwmd.gov
Fri Jun 24 13:23:37 EDT 2011


On Fri, 24 Jun 2011 10:55:52 -0400, Ahmed, Shakir wrote:

> Hi,
> 
> 
>  
> I am getting following error message while unziping a .zip file. Any
> help or idea is highly appreciated.

How do you know it is when unzipping the file? Maybe it is, or maybe it 
isn't. The line giving the error has *two* IO operations, a read and a 
write. Either one could give IOError.

outfile.write(z.read(name))
IOError: (22, 'Invalid argument')

The first thing is to isolate what is causing the error:

data = z.read(name)
outfile.write(data)

Now you can be sure whether it is the read or the write  which causes
the 
error.

Secondly, find out what the argument is. Assuming it is the read, try 
this:

print repr(name)

Can you open the zip file in Winzip or some other zip utility? Does it 
need a password? 

I see you do this:

fh = open('T:\\test\\*.zip', 'rb')

Do you really have a file called *.zip? I find that very hard to 
believe... as I understand it, * is a reserved character in Windows and 
you cannot have a file with that name.

My guess is that the actual error is when you try to open the file in
the 
first place, before any unzipping takes place, but you've messed up the 
line numbers (probably by editing the file after importing it).


-- 
Steven

>>
The problem is happening when it is coming to write option.

The * is not the real name of the zip file, I just hide the name.




More information about the Python-list mailing list