Google Ads API, Their new version of the Google Adwords API returns data in
an object called "GoogleAdsRow". I have not found any use at all for the
native object. The information presented in this format is not usable and
it is quite confusing. I want to print my file to a basic .csv format, but
there is not any type of delimiter or iterable as far as i can tell. So far
I have only been able to print each entire row as a single cell. Not
Helpful :-).
My main function looks like this following. I have provided two examples of
what I have tried with a comment block identifying both attempts:
def main(client, customer_id, page_size):
ga_service = client.get_service('GoogleAdsService', version='v2')
query = ('SELECT ad_group.id, ad_group_criterion.type, '
'ad_group_criterion.criterion_id, '
'ad_group_criterion.keyword.text, '
'ad_group_criterion.keyword.match_type FROM ad_group_criterion '
'WHERE ad_group_criterion.type = KEYWORD')
results = ga_service.search(customer_id, query=query, page_size=page_size)
try:
with open(path, "w", encoding = "utf-8", newline = "") as f:
#with open(path, "w") as csv:
csv_writer = csv.writer(f, delimiter=',')
for row in results:
campaign = row.campaign
csv_writer.writerow([row]) #Prints entire returned row as a
single cell
csv_writer.writerow(row) #Tells me there is no delimiter
The iterable error is as follows
<ipython-input-15-e736ee2d05c9> in main(client, customer_id, page_size)
17 campaign = row.campaign
18 #csv_writer.writerow([row]) #Prints entire returned row
as a single cell
---> 19 csv_writer.writerow(row) #Tells me there is no delimiter
20
21
Error: iterable expected, not GoogleAdsRow
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/cef0f13c-bdab-4723-9835-87548193f8b9%40googlegroups.com.