-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathparse.py
28 lines (23 loc) · 901 Bytes
/
parse.py
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
import json
import pandas as pd
parsed_dict = {}
pp = pprint.PrettyPrinter(indent=3)
keys_keep = ["rrtm_taumol3" ,"solver_mcica_lw" ,"rrtm_kgb7"]
with open("callgraph.json") as f:
data = json.load(f)
# filter the data for easy handeling
# data = { x : data[x] for x in keys_keep}
for i in data.keys():
for j in data[i]:
name, scope, n_file = j.split(" ")
if j not in parsed_dict:
parsed_dict[name] = {}
parsed_dict[name]['scope'] = scope.replace("[","").replace("]","")
parsed_dict[name]['file'] = n_file.replace("(","").replace(")","")
# name scope and file
if name == i:
parsed_dict[name]['parent'] = None
else:
parsed_dict[name]['parent'] = i
df = pd.DataFrame.from_dict(parsed_dict).transpose()
#pp.pprint(parsed_dict)