If you plan to do a lot of ZIP file creation from Python, it's usually a whole lot faster, and may produce smaller files, if you call out to an external utility to do the compression instead of doing it from within the Python zipfile module. You can also pass compression arguments like -9 that produce smaller files. A while back I wrote a wrapper around zipfile that can call out to the external program if available, otherwise it falls back on using internal zipfile. I can send that to you or post it here if it would help you.
regards, -Preston On Thu, Apr 8, 2010 at 4:53 AM, a h <ah.k...@gmail.com> wrote: > thanks... i tried compression as zipfile.ZIP_DEFLATED and it works fine. > Now i used WinRar software to compress a 1.5GB file, it results into a 42MB > file where as using my script it results into 62 MB file. Is it because of > different format, if so, is there any winrar lib or equivalent lib for > python. > > ah > > On Thu, Apr 8, 2010 at 2:56 PM, Werner F. Bruhin <werner.bru...@free.fr>wrote: > >> On 08/04/2010 09:52, a h wrote: >> >>> hi >>> I want to zip a folder using python script. I have written below piece >>> of code, but i found that total size of all file is equal to the size of >>> resultant zip file. so no compression is done. Its just put all the >>> files in a folder and say save it with an extension(.zip). May be i am >>> wrong someway, but i checked it correctly. >>> import zipfile, os >>> archive_list = os.listdir("logs_21-01-2010") >>> # save the files in the archive_list into a PKZIP format .zip file >>> zfilename = "logs_21-01-2010_.zip" >>> zout = zipfile.ZipFile(zfilename, "w") >>> >> I guess/think you need to define compression, see the doc for: >> 12.4.1 ZipFile Objects >> >> class ZipFile(file[, mode[, compression[, allowZip64]]]) >> >> e.g. >> zipfile.ZipFile('afile.zip', "w", zipfile.ZIP_DEFLATED) >> >> Werner >> >>
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32