Old Nabble - Turbogears General - how to return csv data?
Old Nabble - Turbogears General - how to return csv data?: "e.g. like this
@expose(content_type='text/csv')
def csv(self):
stream = StringIO()
writer = csv.writer(stream, dialect='excel')
writer.writerow(['Spam'] * 5 + ['Baked Beans'])
writer.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
output = stream.getvalue()
stream.close()
return output
For creating real Excel files you can use this:
http://www.python-excel.org
- Sent using Google Toolbar"
@expose(content_type='text/csv')
def csv(self):
stream = StringIO()
writer = csv.writer(stream, dialect='excel')
writer.writerow(['Spam'] * 5 + ['Baked Beans'])
writer.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
output = stream.getvalue()
stream.close()
return output
For creating real Excel files you can use this:
http://www.python-excel.org
- Sent using Google Toolbar"
Comments