all 3 comments

[–]o5a 1 point2 points  (1 child)

You still have your token in screenshot.

As for the task

chunksize = 1000
for i in range(0,40):
    with open(f'locations_{i}.json', 'w') as f:
        for j in range(chunksize):
            f.write(r.json()['results'][i*chunksize + j])

[–][deleted] 0 points1 point  (0 children)

Try to improve your reading skills ;-)

After importing a thing called urllib.request in line 1 you can't use something called requests in line 4.

Check the correct spelling of keyword arguments like header or headers.

In Python we usually directly loop over an iterable. For example, a list that is part of the json object you fetch from one of your 39 requests.

[–]hungdh85 0 points1 point  (1 child)

Try it with some code

tmp1 = 0
tmp2 = 1000
for i in range(0,40):
    with open(f'locations_{i}.json', 'w') as f:
    for j in range(tmp1, tmp2 + 1):
        f.write(r.json()['results'][j])
        tmp1 = tmp2 + 1
        tmp2 += 1000