-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.py
More file actions
32 lines (26 loc) · 830 Bytes
/
process.py
File metadata and controls
32 lines (26 loc) · 830 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
import json
import sys
def format_graph_depth_table(node_depths):
"""
Reads a graph depth table from the commandline and removes the depth.uniq column
"""
for row in node_depths:
print(row[: row.rfind("\t")])
def format_json_data(node_depths, mem="segments0"):
"""
Takes a json data file (calyx output) and formats it as above
"""
depths = node_depths["memories"][mem]
print("#node.id\tdepth")
for i in range(len(depths)):
print(f"{i+1}\t{depths[i]}")
if __name__ == "__main__":
"""
Take a commandline arg, gdt or json, to specify which file to convert
"""
format = sys.argv[1]
if format == "gdt":
format_graph_depth_table(sys.stdin.readlines())
elif format == "json":
data = json.load(sys.stdin)
format_json_data(data)