Problem while trying to extract a directory from a zipfile.

R

ralobao

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 ?
 
V

vincent wehren

ralobao said:
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/Cookbook/Python/Recipe/252508
gives you some ideas on how.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top