Non-ascii characters in report data cause Python sample code to choke

124 views
Skip to first unread message

Paul Karayan

unread,
Feb 24, 2016, 8:28:59 AM2/24/16
to AdWords API Forum
I have a Python program that running Adword reports using AWQL similar to the example here:


What I've found is that the program fails with non-ascii characters in the data - for example, if this were a search term:
"blockspring 翻译" (quotes added)

Here's the error message generated:
'ascii' codec can't encode characters in position 6-7: ordinal not in range(128) 

I think this is the culprit:
report_data = StringIO.StringIO()
However, I can't use BytesIO() per suggestion on Stack Overflow or another error results:

TypeError: 'unicode' does not have the buffer interface 



Do you have any suggestions? I find it hard to believe that the sample code wouldn't work for non-ascii characters in the underlying text data but I clearly can't figure it out myself :) Even trying to inject these characters into my data is pretty painful so it's hard to test... so suggestions there would be quite desirable as well.

This may be similar to this issue:

Michael Cloonan (AdWords API Team)

unread,
Feb 24, 2016, 10:52:46 AM2/24/16
to AdWords API Forum
Hello,

For issues with client libraries specifically, please file reports on that library's issue tracker. You can make a new issue on the python library's issue tracker, and the maintainer will determine whether it is a duplicate of the one you mentioned.

I will also let the maintainer know to take a look since the one you linked hasn't been addressed yet.

Regards,
Mike, AdWords API Team
Reply all
Reply to author
Forward
0 new messages