Dennis Hotson wrote:
On Wed, 28 Jul 2004 06:47:49 -0400, Peter Hansen wrote:
Look for the writestr() method of the ZipFile object.
Ahhh... works a treat!
Check the compression rates within the zipfile. I had some
problems with the writestr method:
----
import zipfile, time
zfile = zipfile.ZipFile('test.zip', 'w', zipfile.ZIP_DEFLATED)
data = 'whatever ' * 100
zinfo = zipfile.ZipInfo('message.txt', time.localtime()[:6])
zfile.writestr(zinfo, data)
zfile.close
-----
On my windows system this generates a test.zip file that
contains the message.txt entry but without compression!
(0% compression ratio).
I wasn't motivated enough to find out what exactly is happening
because the file based methods worked properly and turned out
to be a better solution for my problem.
Istvan.