'Python ZipFile giving different namelist than unzipping utility

I have a bunch of timestamped .jpgs in a zip file, and when I open that zip file using Python's ZipFile package, I see three files:

>>> cameraZip = zipfile.ZipFile(zipPath, 'r')
>>> cameraZip.namelist()
['20131108_200152.jpg', '20131108_203158.jpg', '20131108_205521.jpg']

When I unpack the file using Mac OSX's default .zip unexpander, I get 371 files, from '20131101_000159.jpg' up to '20131108_193152.jpg'.

Unzipping this file gives the same result as the .zip unexpander:

$ unzip 2013.11.zip

extracting: 20131101_000159.jpg     
extracting: 20131101_003156.jpg 
...
extracting: 20131108_190155.jpg     
extracting: 20131108_193152.jpg 

Anybody have any idea what's going on?



Solution 1:[1]

Most likely the problem is in zip central directory record, which wasn't correctly flushed when zip file was created. While Python looks for central directory (I guess), other implementations process local file headers and found all of them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nickolay Olshevsky