See 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--one-Table-at-a-time-.
 
No need for StringIO -- just create an open file and pass it to the export 
method (then close the file).

Anthony

On Friday, August 7, 2015 at 2:39:32 PM UTC-4, forumweb...@gmail.com wrote:
>
> He group, 
>
> i create serial letters with web2py and pdfLatex. It works fine with a 
> static csv-file in private folder. 
> But i want to create the csv and save directly to the folder. No Download!
>
> I create the csv ... no Problem:
>
> @auth.requires_login()
> def create_csv():
>     from gluon.contenttype import contenttype
>     import os
>     response.headers['Content-Type'] = contenttype('.csv')
>     response.headers['Content-disposition'] = 'attachment; 
> filename=%s_database.csv' % (
>         request.now
>         )
>     import csv, cStringIO
>     s = cStringIO.StringIO()
>     db((db.grunddaten.id>0)).select().export_to_csv_file(s, 
> delimiter=',', quotechar='"', quoting=csv.QUOTE_NONNUMERIC)
>     return s.getvalue()
>
> But how can i save this file directly on my folder?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to