Thank you very much, Anthony. Your explanation and solution was exactly what I needed.
Eduardo On 4 mar, 00:23, Anthony <abasta...@gmail.com> wrote: > On Thursday, March 3, 2011 1:19:14 PM UTC-5, Eduardo wrote: > > > Thank you all. Editing appadmin will do. I am, however, having a hard > > time identifying export_to_csv( ) either in views/appadmin.html or > > appadmin.py. While import_from_csv is clearly called from within > > appadmin.import_csv, I am unable to identify how export_to_csv is > > called there. > > The export is done by the csv() function in > appadmin.py:http://code.google.com/p/web2py/source/browse/applications/welcome/co... > > That function returns: > > str(db(query).select()) > > The db(query).select() is a DAL Rows object, and since it is passed to > str(), the __str__ method of the Rows class is applied. You can see the > __str__ method of the Rows class in dal.py > here:http://code.google.com/p/web2py/source/browse/gluon/dal.py#4850 > > <http://code.google.com/p/web2py/source/browse/gluon/dal.py#4850As> > As you can see, the __str__ method ultimately calls the export_to_csv_file > method, which is > here:http://code.google.com/p/web2py/source/browse/gluon/dal.py#4947 > > I suppose you could write your own export_tab_delimited function that works > like __str__ but passes delimiter='\t' to export_to_csv_file. Maybe > something like this added to appadmin.py: > > import cStringIO > def export_tab_delimited(rows): > s = cStringIO.StringIO() > rows.export_to_csv_file(s, delimiter='\t') > return s.getvalue() > > And then change the last line of the csv() function to: > > return export_tab_delimited(db(query).select()) > > Anthony