By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,146 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,146 IT Pros & Developers. It's quick & easy.

Problem while trying to extract a directory from a zipfile.

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.