I am trying to store a specific JSON file that resides in each subfolder in a root folder.
I managed to do that and now I have this list:
list_1
which gives:
['C:\\Users\\user\\Downloads\\problem00001\\ground-truth.json',
'C:\\Users\\user\\Downloads\\problem00002\\ground-truth.json',
'C:\\Users\\user\\Downloads\\problem00003\\ground-truth.json']
Now I am trying to open each of these JSON files inside a list but only the last one is stored.
The goal is to store all of them together instead of only the last.
Here is what I tried:
for k in list_1:
with open(k, 'r') as f:
gt = {}
gt2=[]
for i in json.load(f)['ground_truth']:
#print(i) <--- This here prints exactly what I need
gt[i['unknown-text']] = i['true-author']
gt2.append(gt)
I guess in each iteration it gets replaced but not sure.