Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating report containing UTF-8 values #38

Open
georgms opened this issue Feb 10, 2018 · 0 comments
Open

Generating report containing UTF-8 values #38

georgms opened this issue Feb 10, 2018 · 0 comments

Comments

@georgms
Copy link

georgms commented Feb 10, 2018

I am trying to write a CSV report that contains UTF-8 values in the dimension values (specifically ga:searchKeyword).

Generating the report works fine using

report = unicode(query.serialize(format='ascii', with_metadata=False))

However, trying to use the CSV format with

report = unicode(query.serialize(format='csv', with_metadata=False))

will result in the error

Traceback (most recent call last):
  File "google-analytics.py", line 59, in <module>
    report = unicode(query.serialize(format='csv', with_metadata=False))
  File "/usr/local/lib/python2.7/dist-packages/googleanalytics/query.py", line 240, in serialize
    writer.writerows(self.rows)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 14: ordinal not in range(128)

Sadly I'm am pretty inexperienced in Python. I've already tried adding # encoding: utf-8 to google-analytics.py with no success.

Am I using it wrong? How can I generate a CSV report where the values contain UTF-8 characters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant