Python: num_results and total_results_count don't work

35 views
Skip to first unread message

Leo Blanchard

unread,
Oct 16, 2020, 6:16:06 AM10/16/20
to AdWords API and Google Ads API Forum
Hello,

When trying to retrieve the total number of rows in a report via num_results (or total_results_count, which is listed on the documentation but doesn't seem to exist), 0 is returned despite there being results in the report that I am then able to iterate through and return_total_results_count being set to True. The only way I can get it to return an accurate number is by iterating through the rows and then retrieving num_results. Example code below: 

ga_service = client.get_service("GoogleAdsService", version="v5")
    query = """SELECT segments.date,
                        campaign.name,
                        search_term_view.search_term,
                        metrics.impressions
                    FROM search_term_view
                    WHERE segments.date BETWEEN '20201016' AND '20201016'
                ORDER BY segments.date ASC"""    
    search_term_report = ga_service.search(customer_id, query=query, return_total_results_count=True)
print(search_term_report.num_results)
>0
for row in search_term_report:
  #nothing
print(search_term_report.num_results)
> 5

Thanks,

Leo


Google Ads API Forum Advisor Prod

unread,
Oct 16, 2020, 3:50:24 PM10/16/20
to lblan...@merkleinc.com, adwor...@googlegroups.com
Hello Leo,

The Python client library owners are better suited to provide assistance on this issue. You can reach them by creating an issue here.

Regards,
Anthony
Google Ads API Team

Google Logo
Anthony
Google Ads API Team
 
 

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