-
Notifications
You must be signed in to change notification settings - Fork 974
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
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 16383: unexpected end of data #281
Comments
Hello, Thanks for the Report! I'm not able to reproduce on my end with test data, but this is an interesting case because at a glance it certainly looks like this should work. The fact that it works with encoding set to That said, troubleshooting this issue would probably be better handled in the AdWords API Support Forum, I suggest you reach out there. I'll leave this issue open for a while though; in the event that you determine that there is a library-related cause, feel free to follow up. Regards, |
Closing for now, but feel free to reopen if you find anything library-specific at fault. |
OK thank you. I tried to comment but it was not possible. I have asked in
the API forum and hope I will get an answer.
…On Tue, May 8, 2018 at 4:53 PM, msaniscalchi ***@***.***> wrote:
Closed #281 <#281>
.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#281 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AZoXY-cxYdxryHKvqoQpJ_a4XfxhWQITks5twbFbgaJpZM4TxH2V>
.
|
Hi Mark, We can't reproduce this on our end, using both Python 2 and 3, so it seems not an issue on API server. Best, |
O.K. Will do. I'll need to set up a few different environment configurations and see if anything can reproduce this. |
Here is the whole error maessage in case it helps you more
```
Traceback (most recent call last):
File "test.py", line 267, in <module>
client_list.append(tostring(adwords_client, report_name, id))
File "test.py", line 243, in tostring
skip_report_summary=True, include_zero_impressions=True)
File ".../anaconda3/lib/python3.6/site-packages/googleads/common.py",
line 531, in Wrapper
return utility_method(*args, **kwargs)
File ".../anaconda3/lib/python3.6/site-packages/googleads/adwords.py",
line 1292, in DownloadReport
output, **kwargs)
File ".../anaconda3/lib/python3.6/site-packages/googleads/adwords.py",
line 1569, in _DownloadReport
and not isinstance(output, io.BytesIO))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 16383:
unexpected end of data
```
[API Forum issue](
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/adwords-api/AkyJOLLe3aY
)
…On Wed, May 9, 2018 at 3:32 PM, msaniscalchi ***@***.***> wrote:
O.K. Will do. I'll need to set up a few different environment
configurations and see if anything can reproduce this.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#281 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AZoXYymyNfyFhNkrPtJPJ1aspWGJW498ks5twu_6gaJpZM4TxH2V>
.
|
I think I now have a handle on what is going wrong here. The reason you're getting an error indicating an unexpected end of data is because... the decoder is reaching an unexpected end of data. The As a work-around, if you provide a It looks like there's a few improvements we can make here for a future release. Regards, |
I am getting exactly the same error:
The suggested workaround of using ReportDownloader.DownloadReportAsString works, but is not optimal due to size of some larger reports. The issue only started after i upgraded the library from version 10.0.0 to the most recent version as I migrated from API v201710 to v201806 using Python3 Regards, |
Hi Kyle,
using the BytesIO instead of StringIO and the DownloadReport should work.
I am using that with no problem
Regards,
Christos
…On Thu, Jul 5, 2018 at 11:14 AM kyle-IS ***@***.***> wrote:
I am getting exactly the same error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 16383: unexpected end of data
The suggested workaround of using ReportDownloader.DownloadReportAsString
works, but is not optimal due to size of some larger reports.
The issue only started after i upgraded the library from version 10.0.0 to
the most recent version as I migrated from API v201710 to v201806 using
Python3
Regards,
Kyle
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#281 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AZoXY2N1WJWoA6dgrYvXHyBUoGZgYXdzks5uDdjrgaJpZM4TxH2V>
.
|
Ok, thanks Christos. i'll try that out! |
Following code worked for me. In my case, special characters were not important to me. Hence, I removed those characters. response = None
try:
output = open(path, 'a')
response = report_downloader.DownloadReportAsStreamWithAwql(report_query, 'csv',
skip_report_header=False,
skip_column_header=False,
skip_report_summary=False)
while True:
chunk = response.read(16 * 1024)
if not chunk: break
output.write(
''.join(filter(lambda x: x in string.printable, chunk.decode(encoding='utf-8', errors='ignore'))))
output.close()
except Exception as error:
raise Exception(error)
finally:
if response:
response.close() |
For anyone looking for the BytesIO method, I believe it looks something like this (please correct me if you think I've made a mistake):
|
Same issue here. We upgraded from googleads 8.0.0 to googleads 12.2.0 / 13.0.0 (v201702 to v201806) and this exception raised:
Our code (we do not use StringIO):
In our case, exception only raises sometimes. Only for debug purposes we do a while:
And this is the unexpected output:
Something weird it is happenning on ReportDownloader.DownloadReport We can use ReportDownloader.DownloadReportAsString as a workarround (it is working), but we think is important to fix ReportDownloader.DownloadReport to do not break the client library interface. |
still happens |
HI,
after long searching for a solution to my problem I have to ask here for help.
I am getting the error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 16383: unexpected end of data
while trying to download an Ad Perfromance report as string in memory with the DownloadReport function or as stream with DownloadReportAsStream function.
The problem comes from the AdGroupName field that contains german characters like ä, ü, ö.
I am not receiving any error though when I use the DownloadReportAsStream function to write the report in a .csv file or when I force the decoding to be 'latin-1' with
I am using Python 3, API v201802 and the locale in the container is set to be C.UTF-8.
Below are the functions which are mostly copied from AdWords API documentation.
write in csv (working):
stream with latin-1 (working):
write to string (not working):
The text was updated successfully, but these errors were encountered: