472,365 Members | 1,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,365 software developers and data experts.

Zipping and Unzipping files

Is there a simple way to zip and unzip files?

I'm looking for something along the lines of:

zfile = zipfile(r'c:\somefile.zip')
zfile.extract(r'c:\somefiles')

I've looked at the documentation for zlib and zipfile, and they seem
pretty comprehensive, but also extremely low level. If needed, I can
probably make a workable component from them, but I was wondering if
there is one already written that I'm just missing.
--
Doug Tolton
(format t "~a@~a~a.~a" "dtolton" "ya" "hoo" "com")

Jul 18 '05 #1
1 9719
Doug Tolton wrote:

Is there a simple way to zip and unzip files?

I'm looking for something along the lines of:

zfile = zipfile(r'c:\somefile.zip')
zfile.extract(r'c:\somefiles')

I've looked at the documentation for zlib and zipfile, and they seem
pretty comprehensive, but also extremely low level. If needed, I can
probably make a workable component from them, but I was wondering if
there is one already written that I'm just missing.


Probably not, since it's likely to require slight differences in
each application. Try this (untested):

import os, zipfile
def extract(self, todir=''):
for name in self.namelist():
f = open(os.path.join(todir, name), 'wb')
f.write(self.read(name))
f.close()

zipfile.ZipFile.extract = extract

Now you should be able to execute the two example lines you showed above...

-Peter
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: seash | last post by:
H My application creates two files , i have to zip these two files to a a single file, how to use winzip functionality in c# Is there any builtin functions available with visual c# the two file...
0
by: Benjamin Bittner | last post by:
hallo ng, first of all, for the zipping progress i use the ziplib from http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx now to my problem. im trying to build a little application...
9
by: ReidarT | last post by:
How can I zip (compress) a file in vs2005 with windows own zip-program? reidarT
6
by: reidarT | last post by:
I will develop a backup routine with local files (zipped) to an internet server via ftp. How do I zip files in Vb.net? reidarT
1
by: Brian | last post by:
Hi all Below is a bit of code that opens up and reads a zip file. I'm having trouble working out how to read in line by line. The file I am unzipping is a CSV file and I need to return each...
2
by: puneetshadija | last post by:
Hello everyone, I want to zip all the files in a folder in an web application, can you suggest me, so as to how can this be done. I did refer to an article posted in Code Project, but its...
1
by: durumdara | last post by:
Hi! As I experienced in the year 2006, the Python's zip module is not unicode-safe. With the hungarian filenames I got wrong result. I need to convert iso-8859-2 to cp852 chset to get good...
0
by: avik1612 | last post by:
Hi, I have created a program to unzip the file. It is unzipping the zip files when put in directory i.e folder inside folder but when i create a zip file without putting in a folder and try to...
2
by: karen.google | last post by:
I have an SSIS package that I'm converting from DTS (SQLServer 2005), and the ActiveX Script Task (in VBScript) is deprecated, so I'm trying to convert things to Script tasks (in VB .net). I...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.