BadZipfile "file is not a zip file"

webcomm ryandw at gmail.com
Fri Jan 9 10:05:25 EST 2009


On Jan 9, 3:46 am, Carl Banks <pavlovevide... at gmail.com> wrote:
> The zipfile format is kind of brain dead, you can't tell where the end
> of the file is supposed to be by looking at the header.  If the end of
> file hasn't yet been reached there could be more data.  To make
> matters worse, somehow zip files came to have text comments simply
> appended to the end of them.  (Probably this was for the benefit of
> people who would cat them to the terminal.)
>
> Anyway, if you see something that doesn't adhere to the zipfile
> format, you don't have any foolproof way to know if it's because the
> file is corrupted or if it's just an appended comment.
>
> Most zipfile readers use a heuristic to distinguish.  Python's zipfile
> module just assumes it's corrupted.
>
> The following post from a while back gives a solution that tries to
> snip the comment off so that zipfile module can handle it.  It might
> help you out.
>
> http://groups.google.com/group/comp.lang.python/msg/c2008e48368c6543
>
> Carl Banks

Thanks Carl.  I tried Scott's getzip() function yesterday... I
stumbled upon it in my searches.  It didn't seem to help in my case,
though it did produce a different error:  ValueError, substring not
found.  Not sure what that means.



More information about the Python-list mailing list