Python - CAMPAIGN_PERFORMANCE_REPORT using CSVFOREXCEL

23 views
Skip to first unread message

Juan Carlos Blanco Delgado

unread,
Oct 18, 2019, 9:47:39 AM10/18/19
to AdWords API and Google Ads API Forum
Hello, 

I have a problem download this report, see code below.


.Select('Impressions', 'Clicks', 'Cost')

               
.From('CAMPAIGN_PERFORMANCE_REPORT')
               
.Where('CampaignName').EqualTo(CAMPAIGN_NAME)
               
.Build())




I successfully download the report as a CSV, but the Cost for some reason comes with the decimal point, so I see a massive number instead of a 3 digits numbers.

For CSV I have this code 

output = io.StringIO()


reportDownloader
.DownloadReportWithAwql(
        reportQuery
,
       
'CSV',
        output
,

        client_customer_id
=ID,
        skip_report_header
=False,
        skip_column_header
=False,
        skip_report_summary
=False,
        include_zero_impressions
=False
       
)



I thought to download it as a CSVFOREXCEL , so I changed the format type 




    output
= io.BytesIO()




reportDownloader
.DownloadReportWithAwql(
        reportQuery
,
       
'CSVFOREXCEL',
        output
,

        client_customer_id
=ID,
        skip_report_header
=False,
        skip_column_header
=False,
        skip_report_summary
=False,
        include_zero_impressions
=False
       
)


The problem is the data comes as bytes, and I tried also with io.StringIO() and it does not accep it....

Thank you!!!

Google Ads API Forum Advisor Prod

unread,
Oct 18, 2019, 12:16:36 PM10/18/19
to juancarlos.b...@rs-components.com, adwor...@googlegroups.com
Hello Juan,

In general the cost fields in the report will be shown in the form of micros hence you will see the larger number than what you see in the UI. For example if you have 1.99$ in UI via API you will get cost as (1.99 X 1,000,000) = 1990000. You could also refer this guide for more details. Hope this helps, please let me know if you have any further questions. 

Regards,
Sai Teja, Google Ads API Team.

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