473,406 Members | 2,371 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,406 software developers and data experts.

Problem while trying to extract a directory from a zipfile.

I have this code:

try:
file = zipfile.ZipFile(nome_arquivo)
Gauge.start() #inicia o Gauge
for element in file.namelist():
try:
newFile = open(diretorio + element,"wb")
except:
newFile = open(diretorio + element + '/',"w")
# Gauge
percent = percent + 10
Gauge.update(percent)
Gauge.set_text("Extraindo" + element)
# Extrai
newFile.write(file.read(element))
newFile.close()

But when i try to extract an zipfile with a directory in it the code
returns me an IOErro exception: "It is a directory"

Please how can i solve it ?
Jul 18 '05 #1
1 1582
ralobao wrote:
I have this code:

try:
file = zipfile.ZipFile(nome_arquivo)
Gauge.start() #inicia o Gauge
for element in file.namelist():
try:
newFile = open(diretorio + element,"wb")
except:
newFile = open(diretorio + element + '/',"w")
# Gauge
percent = percent + 10
Gauge.update(percent)
Gauge.set_text("Extraindo" + element)
# Extrai
newFile.write(file.read(element))
newFile.close()

But when i try to extract an zipfile with a directory in it the code
returns me an IOErro exception: "It is a directory"

Please how can i solve it ?


You need to create any directories yourself. Maybe
the recipe at http://aspn.activestate.com/ASPN/Coo.../Recipe/252508
gives you some ideas on how.

HTH

--
Vincent Wehren

Jul 18 '05 #2

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

Similar topics

3
by: Roy Benjamin | last post by:
I'm developing a WEB service for Sun ONE deployment (AppServer7). I'm developing on Windows XP Pro though will deploy on Solaris, Sun AppServer7 includes a XercesImpl.jar in share/lib. 2 kb...
6
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
7
by: Max M | last post by:
I guess that the best approach is calling a shell tool with something like os.popen(). But I cannot seem to find any free tools. Winzip has a command line option, but for registered users only....
2
by: Bulba! | last post by:
Hello everyone, I'm a newbie to Python, learning it and tried to write the script that would read file, zip it, and put in the target directory. I used ZipFile module (code below). It works...
2
by: Renzo | last post by:
Hi, I'm working to create a backup function for a software; in particular, from a directory with 12300 files (Jpg, medium size = 250KB / total size = 2.90GB), i have to create a zip file. I've...
8
by: Xela | last post by:
Hi A have a very annoying problem. I have written java strored procedures for DB2 v8.1. Their deployement and usage is fine as long as the server is a Windows one. But under Solaris 8 and Linux...
7
by: erikcw | last post by:
Hi all, I'm trying to extract zip file (containing an xml file) from an email so I can process it. But I'm running up against some brick walls. I've been googling and reading all afternoon, and...
10
by: vikasini | last post by:
Hi friends, I have a servlet coding where i can download a folder from FTP. The folder is zipped and stored in the FTP server. While the client downloads the zip file the it should be unzipped...
5
by: Neil Crighton | last post by:
I'm using the zipfile library to read a zip file in Windows, and it seems to be adding too many newlines to extracted files. I've found that for extracted text-encoded files, removing all instances...
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.