Below data is grasped from webpage and containing entries as below(like a table with many rows):
entry1: key1: value1-1, key2: value2-1, key3: value3-1
entry2: key1: value1-2, key2: value2-2, key3: value3-2
entry3: key1: value3-1, key2: value2-3, key3: value3-3
......
entry100: key1: value100-1, key2: value100-2, key3: value100-3
how can I use a dictionary to store this data? the data is from a list thus the 'dictionary append' should be done within a loop...
here is my current solution:
case_list = {}
for entry in entries_list:
case = {'key1': value, 'key2': value, 'key3':value }
case_list.update(case)
but the case_list in the end only contains the last case entry... Can somebody please help me on this? I would expect the case_list containing 100 entries w/o any overwriting among entries, and I will need to store it to DB afterwards.
key1: value1-1, key2: value2-1, key3: value3-1
and how you store your entries within file? – Anisaanisecase_list.update(case)
will updatecase_list
with new key/value pairs fromcase
and overwrite values for the existing case. – Rennet