Yep, it is the web, you can't automatically write a file directly to the user's computer (Holy security issues Batman!) but you can provide them the prepared file as a download that they can then save to wherever they want. Doesn't matter if it is CSV or TXT or HTML or PDF or RTF whatever. Definitely note that reponse.header content-type and content-disposition portion of my sample code above, that is what will help you cause the user's browser to download the file with the correct name. There is some StringIO stuff in there too which Khalil mentioned and you'd definitely want for generating the files.
As far as the formatting of strings you bet python & web2py can do it. If you're worried about text alignment and other layout stuff, why not just use HTML templates, that's what web2py is for. If you look around on this list there is also some stuff on generating PDF reports - I think there is a markmin to PDF converter available too. I believe that pyrtf is also in web2py's contrib so you could use that to do Rich Text Format files. Plenty of options out there for you.
On Monday, April 30, 2012 2:54:28 AM UTC-5, Khalil KHAMLICHI wrote:
Raul, when working with the web you always (most of the times) create the files server side and invite user to download it and save it to his file system, this sais you don't need to access the file system yourself, just invite the user to download your file and you are done.
for csv versus txt files, they are both the same thing IF the user is not going to import them into some other software that needs only csv content,
python has a module called StringIO, you can use it as a file and write to it mixed content : simple text and csv data.