473,439 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,439 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 9772
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.