zipfile decompress problems

Scott David Daniels scott.daniels at
Thu Jan 19 17:26:52 EST 2006

Carl Banks wrote:
> Waguy wrote:
>> I am new to python and want to create a process to unzip large numbers of
>> zip files I get from a SOAP application.  The files all have a ZIP extention
>> and can be unzipped using WinZip....
>> Can anyone help with this?  ...
> Another possibility is this: From the documentation:
> "This module does not currently handle ZIP files which have appended
> comments, or multi-disk ZIP files."
> One thing I've noticed is that, when downloading zip files from a
> service of some sort, they often seem to have appended comments.
> ("This file downloaded from, blah blah blah.")

Based on the file Waguy originally sent, you could try using this:

     import zipfile, cStringIO
     def getzip(filename, ignoreable=100):
             return zipfile.ZipFile(filename)
         except zipfile.BadZipfile:
             original = open(filename, 'rb')
                 data =
             position = data.rindex(zipfile.stringEndArchive,
                                    -(22 + ignoreable), -20)
             coredata = cStringIO.StringIO(data[: 22 + position])
             return zipfile.ZipFile(coredata)

--Scott David Daniels
scott.daniels at

More information about the Python-list mailing list