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


Groups > comp.lang.python > #8389

RE: unzip problem

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 <shahmed@sfwmd.gov>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'received:141': 0.03; 'ioerror:': 0.09; 'error:': 0.12; 'wrote:': 0.15; "'rb')": 0.16; 'ioerror.': 0.16; "isn't.": 0.16; 'it).': 0.16; 'argument': 0.16; 'operations,': 0.16; 'this:': 0.16; 'happening': 0.19; 'importing': 0.19; 'subject:problem': 0.19; 'to:2**1': 0.21; 'file,': 0.22; 'maybe': 0.22; 'header:In-Reply-To:1': 0.22; 'windows': 0.27; 'fri,': 0.28; 'guess': 0.28; 'character': 0.28; 'problem': 0.29; 'hi,': 0.30; 'print': 0.32; 'file.': 0.32; 'error': 0.33; 'does': 0.33; 'to:addr:python-list': 0.34; 'causing': 0.34; 'option.': 0.35; 'actual': 0.35; 'file': 0.36; 'charset:us-ascii': 0.36; 'idea': 0.36; 'skip:o 20': 0.36; 'error.': 0.36; 'assuming': 0.37; 'open': 0.37; 'but': 0.37; 'some': 0.37; 'getting': 0.38; 'could': 0.38; 'takes': 0.38; 'steven': 0.38; 'subject:: ': 0.38; 'data': 0.39; 'help': 0.39; 'to:addr:python.org': 0.39; 'appreciated.': 0.40; 'read,': 0.40; 'called': 0.40; 'give': 0.60; 'zip': 0.65; 'jun': 0.67; 'isolate': 0.84; 'messed': 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:23:37 -0400
In-Reply-To <4e04ae66$0$29975$c3e8da3$5496439d@news.astraweb.com>
X-MS-Has-Attach
X-MS-TNEF-Correlator
Thread-Topic unzip problem
Thread-Index AcwyhMCL+JW3f4eFQ8GROcijMFDBKQADn0BA
References <mailman.371.1308928216.1164.python-list@python.org> <4e04ae66$0$29975$c3e8da3$5496439d@news.astraweb.com>
From "Ahmed, Shakir" <shahmed@sfwmd.gov>
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>, <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.373.1308936224.1164.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 82.94.164.166
X-Trace 1308936224 news.xs4all.nl 200 [::ffff:82.94.164.166]:57425
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8389

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

unzip problem "Ahmed, Shakir" <shahmed@sfwmd.gov> - 2011-06-24 10:55 -0400
  Re: unzip problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-24 15:33 +0000
    RE: unzip problem "Ahmed, Shakir" <shahmed@sfwmd.gov> - 2011-06-24 13:23 -0400
      RE: unzip problem steve+comp.lang.python@pearwood.info - 2011-06-25 03:55 +1000

csiph-web