Skip to content
Advertisement

Tag: python-zipfile

ZipFile does not store any text inside an archived file

The following code results in the file found in the zip being empty, instead of having some text in it: Answer Add flush to the file object: This problem also affects normal (non-temporary) files, so they’ll also need the flush treatment: Alternatively, de-denting the 2nd with block would avoid having to use flush since a file gets closed automatically when

Python zipfile module doesn’t compress files

I have a problem with compression in Python. I know I should call the ZIP_DEFLATED method when writing to make the zip file compressed, but it does not work for me. I have 3 PDF documents in the C:zip directory. When I run the following code it works just fine: It makes the test.zip file without the compression. When I

Faster alternative to Python’s zipfile module?

Is there a noticeably faster alternative to Python 2.7.4 zipfile module (with ZIP_DEFLATED) for zipping a large number of files into a single zip file? I had a look at czipfile https://pypi.python.org/pypi/czipfile/1.0.0, but that appears to be focused on faster decrypting (not compressing). I am routinely having to process a large number of image files (~12,000 files of a combination

Opening zipfile of unsupported compression-type silently returns empty filestream, instead of throwing exception

Seem to be knocking my head off a newbie error and I am not a newbie. I have a 1.2G known-good zipfile ‘train.zip’ containing a 3.5G file ‘train.csv’. I open the zipfile and file itself without any exceptions (no LargeZipFile), but the resulting filestream appears to be empty. (UNIX ‘unzip -c …’ confirms it is good) The file objects returned

Is python zipfile thread-safe?

In a django project, I need to generate some pdf files for objects in db. Since each file takes a few seconds to generate, I use celery to run tasks asynchronously. Problem is, I need to add each file to a zip archive. I was planning to use the python zipfile module, but different tasks can be run in different

Advertisement