PDA

View Full Version : python + zip a created file



somebodyhelpme
December 11th, 2008, 05:48 AM
if form.accepts(request.vars,session):
for table in db.tables:
rows=db(db[table].id).select()
print rows
open(str(os.sep).join([os.getcwd(), 'applications',
request.application, 'databases',
table+'.csv']),'w').write(str(db(db[table].id).select()))


can someone help me how to zip above file?? thanks

ghostdog74
December 11th, 2008, 07:04 AM
read the reference library for gzip or tarfile module.

Greyed
December 11th, 2008, 07:09 AM
if form.accepts(request.vars,session):
for table in db.tables:
rows=db(db[table].id).select()
print rows
open(str(os.sep).join([os.getcwd(), 'applications', request.application,
'databases', table+'.csv']),'w').write(str(db(db[table].id).select()))


Ahhh, much better. Code blocks are your friend, especially with Python. ;)