-
-
Save antonga23/5657c3bc78ac319be1a1f8acdd070602 to your computer and use it in GitHub Desktop.
#python #flask #pandas Using flask to return a csv response from a dataframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import StringIO | |
from flask import Flask, Response | |
@app.route('/some_dataframe.csv') | |
def output_dataframe_csv(): | |
output = StringIO.StringIO() | |
some_dataframe.to_csv(output) | |
return Response(output.getvalue(), mimetype="text/csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment