-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjson_load.py
More file actions
42 lines (36 loc) · 1014 Bytes
/
json_load.py
File metadata and controls
42 lines (36 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
def read_json():
file = open("fake.json",'r',encoding='utf-8')
content=file.readlines()
for i in content:
lists=eval(i)
truck = 0
suv = 0
bus = 0
van = 0
pickup = 0
sedan = 0
for j in lists['preds']:
if j['label'] == 'truck':
truck += 1
elif j['label'] == 'suv':
suv += 1
elif j['label'] == 'bus':
bus += 1
elif j['label'] == 'van':
van += 1
elif j['label'] == 'pickup':
pickup += 1
elif j['label'] == 'sedan':
sedan += 1
lists['truck']=truck
lists['suv']=suv
lists['bus'] =bus
lists['van'] =van
lists['pickup'] =pickup
lists['sedan'] =sedan
#dicts.pop('preds')
print(lists)
#print(json.dumps(i))
if __name__ == '__main__':
read_json()