Hi Martin,
AdWords API doesn't provide a way to detect if an account has stats
beforehand, so there's no way to avoid downloading the file. However, you
could save the trouble of saving the report to file and then loading it.
See
https://github.com/googleads/googleads-python-lib/blob/master/adspygoogle/adwords/ReportDownloader.py
for details. If you pass fileObj as None, then you get the report text
itself as a string.
Cheers,
Anash P. Oommen,
AdWords API Advisor.
On Tuesday, December 31, 2013 7:49:12 AM UTC-5, Martin wrote:
>
> I've got to download SearchQueryPerformanceReposrts for some accounts.
> Some of them haven't had keywords triggered in the selected during clause
> (e.g. YESTERDAY). In that case I'd like to avoid downloading the file
> rather than deleting the file if it is empty. What I'm looking for is to
> speed up my code. Any suggestions?
>
> This is what I'm currently doing in Python and although it get the job
> done it isn't good enough for me.
>
> with open(path.replace('.csv.gz', '.tsv'), 'rb') as testing:
> tsv_reader = csv.reader(testing, delimiter = '\t', quotechar = '"')
> tsv_reader.next(); tsv_reader.next()
> if tsv_reader.next()[0] == 'Total':
> testing.close()
> try:
> os.unlink(path.replace('.csv.gz', '.tsv'))
> except:
> raise
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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].
For more options, visit https://groups.google.com/groups/opt_out.