Re: Flask – how to write csv file & save using prefilled value of the filename (response.headers["Content-Disposition"]="attachment; filename=xxx")
MRAB
python at mrabarnett.plus.com
Fri Aug 6 12:13:54 EDT 2021
On 2021-08-06 16:50, Suretha Weweje wrote:
> I am trying to upload a CSV file with flask, read and process one line at a
> time while iterating through all rows of the file and write the results
> back to a new CSV file. My python script produces the correct results on
> its own, but I am not able to get the same results when using Flask. I am
> new to flask.
>
[snip]
>
> csv_reader = csv.reader(new)
>
[snip]
>
> *mywriter = csv.DictWriter('results.csv', fieldnames=headers_new)*
[snip]
The problem has nothing to do with Flask.
'csv.reader' and 'csv.DictWriter' expect a file object, but you're
passing them strings.
More information about the Python-list
mailing list