csv files for download

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bobby Roberts

    csv files for download

    I need to be able to offer a client "click to download" functionality
    on their website. Generating the data to provide to them is not an
    issue but I want them to be able to click a button and have the
    response be sent to a csv file which they are prompted to download.
    Can someone point me in the right direction how to do this in python.
    Thanks in advance.
  • Rob Williscroft

    #2
    Re: csv files for download

    Bobby Roberts wrote in news:cdc29298-d005-4804-b407-81ecaf6bb1b4@
    2g2000hsn.googl egroups.com in comp.lang.pytho n:
    I need to be able to offer a client "click to download" functionality
    on their website. Generating the data to provide to them is not an
    issue but I want them to be able to click a button and have the
    response be sent to a csv file which they are prompted to download.
    Can someone point me in the right direction how to do this in python.
    Thanks in advance.
    Assuming your using WSGI (you don't say) it would be something like this:

    def wsgi( environ, start_response ):
    start_response( '200 OK', [
    ('Content-Type','text/csv'),
    ('Content-Disposition', 'attachment; filename=whatev er.csv')
    ])
    ...

    If your using cgi it will be something like:

    print "Content-Type: text/csv"
    print 'Content-Disposition: attachment; filename=whatev er.csv'
    print
    ....


    The official home of the Python Programming Language


    Rob.
    --

    Comment

    Working...