DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   File Compression (http://www.daniweb.com/forums/thread67712.html)

sneekula Jan 18th, 2007 12:36 pm
File Compression
 
Since there is so much discussion on one of the threads on zipping/unzipping files and all the associated incompatibilities, is there a way to do this with Python and cut out the middleman?

vegaseat Jan 18th, 2007 6:56 pm
Re: File Compression
 
Python offers a number of modules providing easy file compression and decompression. Here are code snippets for two of the popular compression formats ...
zipfile -->
http://www.daniweb.com/code/snippet629.html
tarfile -->
http://www.daniweb.com/code/snippet630.html

sneekula Jan 21st, 2007 12:05 pm
Re: File Compression
 
Quote:

Originally Posted by vegaseat (Post 303189)
Python offers a number of modules providing easy file compression and decompression. Here are code snippets for two of the popular compression formats ...
zipfile -->
http://www.daniweb.com/code/snippet629.html
tarfile -->
http://www.daniweb.com/code/snippet630.html

Now that is fairly easy code to work with. I didn't know it was that simple. Does anyone have a particular preference of a compression format?

sneekula Jan 21st, 2007 2:20 pm
Re: File Compression
 
Another question, can zipfile archive several files like tarfile? How would you save the decompresed files?

vegaseat Jan 21st, 2007 4:29 pm
Re: File Compression
 
Quote:

Originally Posted by sneekula (Post 304212)
Another question, can zipfile archive several files like tarfile? How would you save the decompresed files?

An omission on my part, I added another snippet to show you how to pack and unpack files to and from an archived zip file:
http://www.daniweb.com/code/snippet633.html


All times are GMT -4. The time now is 5:57 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC