Unhelpful traceback

Chris Rebert clp2 at rebertia.com
Thu Mar 7 02:04:00 EST 2013


On Wed, Mar 6, 2013 at 10:33 PM, John Nagle <nagle at animats.com> wrote:
> Here's a traceback that's not helping:
<snip>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in
> position 14: ordinal not in range(128)
<snip>
> The program is converting some .CSV files that come packaged in .ZIP
> files.  The files are big, so rather than expanding them, they're
> read directly from the ZIP files and processed through the ZIP
> and CSV modules.
<snip>
> This works for data records that are pure ASCII, but as soon as some
> non-ASCII character comes through, it fails.

I'd recommend using the `unicodecsv` package, which, unlike the std
lib `csv` module, is properly Unicode-compatible:
https://pypi.python.org/pypi/unicodecsv

Cheers,
Chris



More information about the Python-list mailing list