[Tutor] Urgent: unicode problems writing CSV file

CMG Thrissur cmgcomsol at gmail.com
Thu Jun 9 11:47:37 EDT 2016



On Wednesday 08 June 2016 07:24 PM, Alex Hall wrote:
> All,
> I'm working on a project that writes CSV files, and I have to get it done
> very soon. I've done this before, but I'm suddenly hitting a problem with
> unicode conversions. I'm trying to write data, but getting the standard
> cannot encode character: ordinal not in range(128)
>
> I've tried
> str(info).encode("utf8")
> str(info).decode(utf8")
> unicode(info, "utf8")
> csvFile = open("myFile.csv", "wb", encoding="utf-8") #invalid keyword
> argument
>
> What else can I do? As I said, I really have to get this working soon, but
> I'm stuck on this stupid unicode thing. Any ideas will be great. Thanks.
>
Hi,

How about opening file with setting the encoding = utf8.

This solved most of my problems.

George


More information about the Tutor mailing list