Python with ZIP64 extension when compressing large files

I have a script that compresses the output files. The problem is that one of the files exceeds 4Gigs. How do I convert my script to use ZIP64 extensions instead of the standard zip?

This is how I clamp it now:

try: import zlib compression = zipfile.ZIP_DEFLATED except: compression = zipfile.ZIP_STORED modes = { zipfile.ZIP_DEFLATED: 'deflated', zipfile.ZIP_STORED: 'stored', } compressed_name = 'edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip' print 'creating archive' zf = zipfile.ZipFile('edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip', mode='w') try: zf.write(name1, compress_type=compression) zf.write(name2, compress_type=compression) zf.write(name3, compress_type=compression) finally: print 'closing' zf.close() 

Thanks! Bill

+8
python zip zlib zipfile
source share
2 answers

Check out the zipfile-objects .

You can do it:

 zf = zipfile.ZipFile('edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip', mode='w', allowZip64 = True) 
+12
source share

Like this:

 zf = zipfile.ZipFile('edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip', mode='w', allowZip64=True) 
+5
source share

All Articles