Using Flask To Return Multiple Dataframes As Csv
I've multiple dataframes and i want to return multiple downloadable CSV files using flask. I tried following code but it can only return one downloadable CSV file. resp = make_resp
Solution 1:
I got my answer, Actually there is no way to return all files at once using flask only so i made a zip file containing all CSVs and then returned it.
import zipfile
with zipfile.ZipFile('main_code/output.zip', 'w') as csv_zip:
csv_zip.writestr("data1.csv", data1.to_csv())
csv_zip.writestr("data2.csv", data2.to_csv())
return send_file('output.zip',
mimetype='zip',
attachment_filename='output.zip',
as_attachment=True)
Post a Comment for "Using Flask To Return Multiple Dataframes As Csv"