You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
If I remove the encode method call, export works as expected.
deflist_to_csv_response(data, title="report", header=None, widths=None):
""" Make 2D list into a csv response for download data. """response=HttpResponse(content_type="text/csv; charset=UTF-8")
cw=csv.writer(response)
forrowinchain([header] ifheaderelse [], data):
cw.writerow([force_text(s) forsinrow])
returnresponse
Maybe this is Python 2 & 3 compatibility issue. I can guess that on Python 2 CSV writer expect str instead of Unicode. And on Python 3 it expects str instead of bytes.
Please, let me know if I can help somehow to resolve it.
Regards, Artem.
The text was updated successfully, but these errors were encountered:
# for freeto subscribe to this conversation on GitHub.
Already have an account?
#.
django-export-action==0.1.1
django==1.11.9
3.6.5
Description
When I trying to export char field of the model into CSV format I got repr() of the string encoded to bytes instead of the string itself.
But instead of this, I expect the string value itself.
What I Did
I trace execution to the
export_action.report.list_to_csv_response
function. It contains this lineIf I remove the
encode
method call, export works as expected.Maybe this is Python 2 & 3 compatibility issue. I can guess that on Python 2 CSV writer expect
str
instead of Unicode. And on Python 3 it expectsstr
instead ofbytes
.Please, let me know if I can help somehow to resolve it.
Regards, Artem.
The text was updated successfully, but these errors were encountered: