473,837 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(pe rcent)
Gauge.set_text( "Extraindo" + element)
# Extrai
newFile.write(f ile.read(elemen t))
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 1603
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(pe rcent)
Gauge.set_text( "Extraindo" + element)
# Extrai
newFile.write(f ile.read(elemen t))
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
3626
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 different than the one I usually use (xerces-2_1_0). If I compile all my code against the Sun xerces implementation, I get a class-def-not-found-error when trying to write any XML output. java.lang.NoClassDefFoundError:...
6
15232
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
2142
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. That is bothersome if I want to install the script on other machines. The same for pkwares zip. At least I cannot seem to find a free version of it. gzip seems able to do the trick, but I need to install Cygwin, that's
2
3455
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 nice, except the zipfile created contains the directory path of the source file -- which I do NOT want to recreate. E.g. when I compress 'c:\\temp\\zz.txt', the resulting zipfile contains not just 'zz.txt' file, but also the whole directory, i.e....
2
1551
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 decided to use the standard "zipfile" library to do that. This is the code: zipName = path.join(config.get('server.xbakPath'), 'backup.zip') fileExport = zipfile.ZipFile(zipName,'w',zipfile.ZIP_DEFLATED)
8
3013
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 RH, the call of sqlj.install_jar fails. It correctly create a directiory with the correct schema name, but the jar is not copied in it. The error is "Permission Denied" SQLSTATE 38501 and in the log, we can see that calling sqlejReadJar fails in...
7
7659
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 can't seem to figure it out. Here is what I have so far. p = POP3("mail.server.com")
10
1543
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 and stored in the client machine. Here is the code.. import javax.servlet.http.*; import javax.servlet.*;
5
5174
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 of '\r' in the extracted file seems to fix the problem, but I can't find an easy solution for binary files. The code I'm using is something like: from zipfile import Zipfile z = Zipfile(open('zippedfile.zip'))
0
9837
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9682
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10563
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10621
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9392
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7804
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5668
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4038
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.