Hi, i'm trying to pull the data using the DownloadReportAsStream method and
there are issues downloading data where i'm seeing a malformed string (not
all columns posted).
I'm kind of surprised as to why all data is not downloaded.
Could you please let me know if there are any known issues with this
approach?
Here is my code snippet:
"id" used below is the accountId.
report_definition = {
'dateRangeType': 'CUSTOM_DATE',
'downloadFormat': 'CSV',
'includeZeroImpressions': 'false',
'reportName': 'Daily Adwords Digest',
'reportType': 'AD_PERFORMANCE_REPORT',
'selector': {
'dateRange': {
'min': start_dt, # format is '20141117'
'max': end_dt
},
'fields': REPORT_COLUMNS,
}
}
CHUNK_SIZE = 32 * 1024
report_data = StringIO.StringIO()
stream_data = report_downloader.DownloadReportAsStream(
report_definition, skip_report_header=True, skip_column_header=True,
skip_report_summary=True, include_zero_impressions=False)
try:
while True:
chunk = stream_data.read(CHUNK_SIZE)
if not chunk: break
report_data.write(chunk.decode() if sys.version_info[0] == 3
and getattr(report_data,
'mode', 'w') == 'w' else chunk)
#report_data.seek(0)
#time.sleep(5)
data = report_data.getvalue()
#for line in report_data.split("\n"):
for line in data.split("\n"):
f.write("{},{}\n".format(id, line))
cnt += 1
except Exception as e:
logging.error("Failed to download data for AccountID %s" % id)
raise e
finally:
report_data.close()
stream_data.close()
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/8dd18abd-1ba8-4dde-b877-ae15b250ab38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.