I have found a working solution. This will go something like this:
```
import proto 
response = ga_service.search_stream(search_request) 
for batch in response: 
      for row in batch.results: 
               logging.debug(proto.Message.to_dict(row))
```
On Tuesday, September 8, 2020 at 6:33:16 PM UTC+5:30 kol...@exito.de wrote:

> We are using the Python client library because we don't want to write all 
> the basic stuff.
>
> In the meantime I found out how you can directly convert the API result to 
> a pandas dataframe in Python:
>
> from pandas import json_normalize
> from google.protobuf.json_format import MessageToJson
> ...
>
> results_report = ga_service.search(account_id, query=query_report, 
> page_size=_DEFAULT_PAGE_SIZE)
>
> list_all_rows = []
>
> for row in results_report:  
>     serialized_json = MessageToJson(row).replace('\n', '')    
>     serialized_json_dict = json.loads(serialized_json)
>     
>     df_row = json_normalize(serialized_json_dict)  
>     list_all_rows.append(df_row)
>
> if len(list_all_rows) == 0:
>     continue
>
> df_all_rows = pd.concat(list_all_rows)
>
>
> This works fine in Ads API v4 and v5. The same code works for 5 or 50 
> columns.
> TBH: I can't understand why you don't provide such a compact 
> transformation from the API result to a dataframe in your library examples.
>
> Who wants to retrieve every single field like this (taken from the 
> examples)?  That's awkward and tedious  ;-)
>
> for row in results:
>      ad_group = row.ad_group
>      ad_group_criterion = row.ad_group_criterion
>      keyword = row.ad_group_criterion.keyword  
>      ... 
>
> adsapiforumadvisor schrieb am Montag, 20. Juli 2020 um 15:30:55 UTC+2:
>
>> Hi Thomas,
>>
>> Thank you for reaching out. I just want to confirm that you're following 
>> this 
>> example 
>> <https://developers.google.com/google-ads/api/docs/concepts/curl-example> 
>> when making the cURL request to get the JSON response. If so, please share 
>> your client customer ID, cURL request, and any additional error details *via 
>> Reply privately to author *so I can further investigate the issue.
>>
>> Regards,
>> Mitchell
>>
>> Google Ads API Team
>>
>> ref:_00D1U1174p._5004Q21msBS:ref
>>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/1d5d1d31-a39c-41be-9685-6c0b9e3a3de1n%40googlegroups.com.

Reply via email to