Sorry, I don't understand what you mean by divide search results. As for headers, you could do:
... return 'A1,B1,C1\n' + '\n'.join([','.join(map(str,[r.id, r.num, r.ves, r.dt, r.usr])) for r in rr]) On May 2, 2:42 pm, cyber <vlad.mul...@gmail.com> wrote: > Denes, it works. Thanks! > But how to divide search results? > Finaly I want each table field to be into personal column in the row > in csv file. > For example, r.id should be into A1, r.num should be into B1 etc. > Is it possible? > > ********************************************************************* > > On 2 май, 00:27, DenesL <denes1...@yahoo.ca> wrote: > > > > > > > > > You can provide a link to the controller below, instructing the user > > to right click on it and then select 'save link as...', he can store > > the response in any selected directory using his choice of filename (a > > name ending in .csv): > > > def tocsv(): > > response.headers['content-type']='text/csv' > > rr=db((db.autos.dt>=t1) & > > (db.autos.dt<=t2)).select(orderby=~db.autos.dt) > > return '\n'.join([','.join(map(str,[r.id, r.num, r.ves, r.dt, > > r.usr])) for r in rr])