Trouble Downloading ACCOUNT_PERFORMANCE_REPORT to a CSVFOREXCEL

15 views
Skip to first unread message

Matt Orehek

unread,
Jun 27, 2019, 5:11:49 PM6/27/19
to AdWords API and Google Ads API Forum
Hello,

I am struggling to convert an Account Performance Report into a CSVFOREXCEL. I've tried using both report_downloader.DownloadReport and report_downloader.DownloadReportWithAWQL.

I have been using the code examples from the Documentation:


  # Create report query.
  report_query
= (adwords.ReportQueryBuilder()
                 
.Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',
                         
'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',
                         
'Cost')
                 
.From('CRITERIA_PERFORMANCE_REPORT')
                 
.Where('Status').In('ENABLED', 'PAUSED')
                 
.During('LAST_7_DAYS')
                 
.Build())

 
# You can provide a file object to write the output to. For this
 
# demonstration we use sys.stdout to write the report to the screen.
  report_downloader
.DownloadReportWithAwql(
      report_query
, 'CSV', sys.stdout, skip_report_header=False,
      skip_column_header
=False, skip_report_summary=False,
      include_zero_impressions
=True)


However, when I change the download type from CSV to CSVFOREXCEL, I begin to get this error:

'UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte'

Also, when I try providing a file object PATH
PATH = r'C:\Users\morehek\intraday.csv'

 in the place of  sys.stdout, I receive errors that I cannot write the output to a string object. 

Can someone on the Adwords team please advise me on how to cleanly write a report download into a Microsoft Excel CSV? 

Thanks
-Matt






Google Ads API Forum Advisor Prod

unread,
Jun 28, 2019, 3:20:08 AM6/28/19
to adwor...@googlegroups.com
Hi Matt,

Thanks for reaching out. I tried your request using my test account and the Java client library, however, I did not encounter the UnicodeDecodeError when I applied the CSVFOREXCEL setting and ran the report.

That being said, this issue might be client library specific. You may reach out to the Python client library owners via this link for further assistance.

Best regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UCZu4c:ref
Reply all
Reply to author
Forward
0 new messages