Last active
December 20, 2016 20:36
-
-
Save dobrych/8f2a27d179f321bfc0454a1c31caeb23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fetch_batch(page=0): | |
while True: | |
res = API.datasets(DATASET_ID).area().get( | |
apikey=APIKEY, | |
polygon=POLYGON, | |
count=PAGESIZE, | |
var=VARIABLE, | |
offset=PAGESIZE * page, | |
grouping='location', | |
) | |
yield res | |
# continue to "paginate" while nextOffset is present | |
if 'stats' in res and 'nextOffset' in res['stats']: | |
page += 1 | |
else: # stop "pagination" | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment