[web2py] Re: deal with CSV

2011-05-03 Thread cyber
I mean that after export each row is located into one cell (if I open *.csv file in ms excel). For example, if result returns two rows all values from first row are located into A1 cell and the second one - into A2 cell. So, I need to divide each row by columns. Current divider is ,. Is there a

[web2py] Re: deal with CSV

2011-05-03 Thread DenesL
Are you running Windows?. Check that your list separator (which Excel uses) is set to a comma or change the delimiter used in the code. You can find the list separator in the Control Panel, under Regional Settings, Customize. On May 3, 7:38 am, cyber vlad.mul...@gmail.com wrote: I mean that

[web2py] Re: deal with CSV

2011-05-03 Thread cyber
My experiments gave the following results. def export_day(): response.headers['content-type']='text/csv' response.headers['Content-disposition'] = 'attachment; filename=export.csv' results=db(db.autos.dt=date).select(orderby=~db.autos.dt) return

[web2py] Re: deal with CSV

2011-05-03 Thread DenesL
You are welcome. Note: if you have strings you don't need map(str,...) and that \n at the end of 'usr\n' must be causing a blank line, so '\n'.join([';'.join(map(str,['id','num','ves','dt','usr\n']))]) can be just '%s\n' %';'.join('id num ves dt usr'.split()) On May 3, 3:46 pm, cyber

[web2py] Re: deal with CSV

2011-05-02 Thread cyber
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

[web2py] Re: deal with CSV

2011-05-02 Thread DenesL
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

[web2py] Re: deal with CSV

2011-05-01 Thread cyber
Any ideas please! * On 1 май, 00:20, cyber vlad.mul...@gmail.com wrote: hi everyone! I need a help/hint/advase again. I have a code in the controller: results=db((db.autos.dt=t1) (db.autos.dt=t2)).select(orderby=~db.autos.dt)     export

[web2py] Re: deal with CSV

2011-05-01 Thread DenesL
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'