473,398 Members | 2,368 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,398 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 9770
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.