Skip to content

Instantly share code, notes, and snippets.

@dobrych
Last active December 20, 2016 20:36
Show Gist options
  • Save dobrych/8f2a27d179f321bfc0454a1c31caeb23 to your computer and use it in GitHub Desktop.
Save dobrych/8f2a27d179f321bfc0454a1c31caeb23 to your computer and use it in GitHub Desktop.
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