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 >
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32