473,395 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can't get compression in Python zip script.

Hello,
I following an example on how to zip files from the www.devshed.com
site.
I can create a zip package, however I am not getting any compression.
120M file stays 120M within the zip package.
I need to know how to set or activate the compression values.
here is the code I'm using:
import zipfile
zip = zipfile.ZipFile('<path/zipfilename.zip>', 'w')
zip.write('<path/filename.txt>')
zip.close()


Any help would be gratly appreciated

deej

Jul 19 '05 #1
1 1684
zipfile.ZipFile.__init__(self, filename, mode='r', compression=0)
Open the ZIP file with mode read "r", write "w" or append "a".
import zipfile
zip = zipfile.ZipFile('<path/zipfilename.zip>', 'w', compression=1)
zip.write('<path/filename.txt>')
zip.close()


Warning about zipfile module:
In Python2.2 this is true, maybe 2.3 and 2.4 also have some problems.
You cannot remove/delete an entry from a zipfile with Python but you
can read and write it!
To do it you will have to make a new zip file that contains all the
files you want to keep and then overwrite the original.
You can have mulitple files with the same name!
Obviusly that can cause problems.
This can be very confusing.
hth,
M.E.Farmer

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jay Donnell | last post by:
Is there a way to use the tarfile module to recursively compress the contents of a directory and maintain the directory structure in the tar archive? Simply doing os.system('tar -czvf ' +...
24
by: c3poptuse | last post by:
Supercomputer and encryption and compression @ rate of 96% Take a document then or a 3D matrix document change it two random or binary code or just a program for 0's and 1's and fold it over and...
14
by: George Hester | last post by:
http://hesterloli.dnsalias.com/test/javascript_image.htm The image is the 100x100 px block. If we right-click in it and try to save the image we cannot. Is it possible to say set a mime-type so...
8
by: Anurag | last post by:
Hi, I am told that Oracle has this "data compression" feature that allows you to store online data ina compressed format. This is different from archived data - you compress only that data which...
16
by: Claudio Grondi | last post by:
What started as a simple test if it is better to load uncompressed data directly from the harddisk or load compressed data and uncompress it (Windows XP SP 2, Pentium4 3.0 GHz system with 3 GByte...
6
by: Chetan Patil | last post by:
I would like to obfuscate and compress (remove comments, newlines etc) my javascript files / ajax code. Is there a module that will do this on the fly with some level of caching? Does such a...
0
by: kuwanger | last post by:
I've been working on some python code to have an open source apack compression (http://www.ibsensoftware.com/products_aPACK.html is a link to the original proprietary version). Just to clarify the...
1
by: roche.alexis | last post by:
Hi all, I'm looking for a library in python containing severall compression algorithms like RLE, Deflate, LZ77-78-W, Huffman,...... do someone know if such of this type of lib exists?? Thanks
2
by: Rene Maurer | last post by:
Hallo I wonder if there are any pure python implementations available/known for the zip (or any other) data compression... As far as I know python's zlib uses http://www.zlib.net/, which is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.