954,135 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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?

sneekula
Nearly a Posting Maven
2,427 posts since Oct 2006
Reputation Points: 961
Solved Threads: 212
 

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

vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 
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
Nearly a Posting Maven
2,427 posts since Oct 2006
Reputation Points: 961
Solved Threads: 212
 

Another question, can zipfile archive several files like tarfile? How would you save the decompresed files?

sneekula
Nearly a Posting Maven
2,427 posts since Oct 2006
Reputation Points: 961
Solved Threads: 212
 
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

vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You