-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcombine.py
More file actions
26 lines (21 loc) · 829 Bytes
/
combine.py
File metadata and controls
26 lines (21 loc) · 829 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
import json
def extract_key_from_file(filename, key):
"""Extract a specific key's data from a JSON file."""
with open(filename, "r") as f:
data = json.load(f)
return data.get(key, {})
def inputs(pins,nets,devices,pin_connection):
pins_data = extract_key_from_file(pins, "pins")
nets_data = extract_key_from_file(nets, "nets")
devices_data = extract_key_from_file(devices, "device")
pin_connection = extract_key_from_file(pin_connection, "pin_connections")
# Combine the data
combined_data = {
"pins": pins_data,
"nets": nets_data,
"devices": devices_data,
"pin_connections":pin_connection
}
# Write the combined data to a new JSON file
with open("combined.json", "w") as outfile:
json.dump(combined_data, outfile, indent=4)