Dictionary - How To Append Several Dictionaries While Looping Through Pagination (API) - Python 3 - Stack Overflow
Dictionary - How To Append Several Dictionaries While Looping Through Pagination (API) - Python 3 - Stack Overflow
Home
How to append several dictionaries while looping through pagination (API) - Ask Question
PUBLIC python 3
Questions Asked 2 years, 9 months ago Active 2 years, 9 months ago Viewed 989 times
Tags
dataset_all
Join Stack Overflow to learn, share knowledge, = requests.get(url)
and build your career. Sign up with email Sign up with Google Sign up with GitHub Sign up with Facebook
json_dataset_all = dataset_all.json()
json_dataset_all.update()
print(json_dataset_all)
i = i+1
I am not succeeding in going through the loop and updating my dictionary page1 with page2,
Report this ad
page3, page4 and page5.
The 'print' shows that the loop through the pages works, but it's not storing the pages in the
dictionary as it progresses. It only contains the latest page.
+ 5 more benefits
1 Answer Active Oldest Votes
Learn more
The pages have an identical "key" called "entries" and it's value is a list of dictionaries. When you
update your dictionary, it will therefore just overwrite its value (the list of dictionaries).
1 Linked
If you want to have one single list with all the dictionaries, you could do something like this. You
can then also easily put it in a Pandas DataFrame. 1 How do I append the datasets from
pagination responses in Python?
import requests
import pandas as pd Related
Ok cool, this is working fine now! By just running 'df' without 'print', I got now the result I wished for! Supert, Choosing reaction stoichiometry in organic
thanks a lot :-) – AnneE Oct 12 '18 at 13:23 synthesis
Question feed
Not the answer you're looking for? Browse other questions tagged python dictionary for-loop
STACK OVERFLOW PRODUCTS COMPANY STACK EXCHANGE Blog Facebook Twitter LinkedIn Instagram
NETWORK
Questions Teams About
Technology
Jobs Talent Press
Life / Arts
Developer Jobs Directory Advertising Work Here
Culture / Recreation
Salary Calculator Enterprise Legal
Science
Help Privacy Policy
Other
Mobile Terms of Service
Disable Responsiveness Contact Us
Cookie Settings
site design / logo © 2021 Stack Exchange Inc; user contributions
Cookie Policy licensed under cc by-sa. rev 2021.8.3.39902