CSV Export fails due to non ASCII encoding

Reported by dillj on 2011-12-28
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
wxBanker
Medium
Unassigned

Bug Description

When trying to export to CSV (I have non-ASCII characters in the data) I get:
 Traceback (most recent call last):
 File "/usr/lib/python2.7/site-packages/wxbanker/menubar.py", line 176, in onMenuEvent
 handler(event)
 File "/usr/lib/python2.7/site-packages/wxbanker/menubar.py", line 280, in onClickExportCsv
 CsvExporter.Export(self.bankController.Model, csvpath)
 File "/usr/lib/python2.7/site-packages/wxbanker/csvexporter.py", line 28, in Export
 result = CsvExporter.Generate(model)
 File "/usr/lib/python2.7/site-packages/wxbanker/csvexporter.py", line 21, in Generate
 writer.writerow(row)
 UnicodeEncodeError: 'ascii' codec can't encode character u'\u0143' in position 63: ordinal not in range(128)

As reported here -> https://aur.archlinux.org/packages.php?ID=55363

dillj (dillj) wrote :

So it seems that this seems to be a python 2 problem. And apperently it's fixed in python 3.

http://bugs.python.org/issue1606092

Or the non ASCII characters have to be converted to UTF-8

viq (vicviq) wrote :

(I am the original reporter)
'file' claims that the file from which the initial data was importent claims to be "UTF-8 Unicode text"

Michael Rooney (mrooney) wrote :

Thanks, this should be fixable for sure, I'll see what I can do! It probably needs to be more explicitly using a better encoding such as unicode.

PS I had no idea this was packaged for Arch, awesome :D If there are other bugs please do send them this way!

Changed in wxbanker:
status: New → Triaged
importance: Undecided → Medium
milestone: none → 0.9
Valter Vicente (vallovic) wrote :

This bug affected me, so I made a bit of search and found out that you just have to change "writer.writerow(row)" to "writer.writerow([row])" and it will work. Now I can export my information!

Explanation: http://stackoverflow.com/a/1816897

Michael Rooney (mrooney) wrote :

Okay, I just pushed a fix for this towards 0.9, it needed proper utf8 encoding and decoding. Valter, your workaround doesn't actually produce what you want, as the row being passed in was already correctly a list, so with your change, it simply exports a string version of the list as a single value.

Changed in wxbanker:
status: Triaged → Fix Committed
Michael Rooney (mrooney) on 2013-11-20
Changed in wxbanker:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.