BadZipfile "file is not a zip file"
MRAB
google at mrabarnett.plus.com
Thu Jan 8 20:54:54 EST 2009
webcomm wrote:
> On Jan 8, 8:02 pm, MRAB <goo... at mrabarnett.plus.com> wrote:
>> You're just creating a file called "data.zip". That doesn't make it
>> a zip file. A zip file has a specific format. If the file doesn't
>> have that format then the zipfile module will complain.
>
> Hmm. When I open it in Windows or with 7-Zip, it contains a text
> file that has the data I would expect it to have. I guess that alone
> doesn't necessarily prove it's a zip file?
>
> datum is something I'm downloading via a web service. The providers
> of the service say it's a zip file, and have provided a code sample
> in C# (which I know nothing about) that shows how to deal with it.
> In the code sample, the file is base64 decoded and then unzipped.
> I'm trying to write something in Python to decode and unzip the file.
>
> I checked the file for comments and it has none. At least, when I
> view the properties in Windows, there are no comments.
>
Ah, OK. You didn't explicitly say in your original posting that the
decoded data was definitely zipfile data. There was a thread a month ago
about gzip Unix commands which could also handle non-gzipped files and I
was wondering whether this problem was something like that. Have you
tried gzip instead?
More information about the Python-list
mailing list