From 7c068fa8e7cdf6507566bb8f40c3d163a8822e39 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Thu, 31 Oct 2024 18:02:09 -0500 Subject: Finished basic functionality of script, needs to be able to handle ranges of pins. --- tableconversion.py | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'tableconversion.py') diff --git a/tableconversion.py b/tableconversion.py index 15e300f..5fc74a6 100644 --- a/tableconversion.py +++ b/tableconversion.py @@ -1,4 +1,5 @@ import yaml +import numpy import pandas as pd def parse_wireviz_yml(file_path): @@ -6,27 +7,54 @@ def parse_wireviz_yml(file_path): with open(file_path, 'r') as file: data = yaml.safe_load(file) - # Extract the wires and their terminating points - wires = data.get('wires', []) + wires = data['cables'] + connectors = data['connectors'] + connections = data['connections'] wire_info = [] + for connection in connections: + #print(connection[0]) + connectorwpin = str(connection[0]) + connector = connectorwpin[2:connectorwpin.find("':")] + connectorpins = connectorwpin[connectorwpin.find(" [")+2:connectorwpin.rfind("]}")].strip(" ").split(",") + + connectorwires = str(connection[1]) + bundle = connectorwires[2:connectorwires.find("':")] + bundlewires = connectorwires[connectorwires.find(" [")+2:connectorwires.rfind("]}")].split(",") + print(connectorpins) + if len(connection) > 2: + connector2wpin = str(connection[2]) + connector2 = connector2wpin[2:connector2wpin.find("':")] + connector2pins = connector2wpin[connector2wpin.find(" [")+2:connector2wpin.rfind("]}")].split(",") + + for x in range(0,len(connectorpins)): + print(wires[bundle]['length']) + wire_info.append({ + 'End 1': connector, + 'Pin 1': connectorpins[x], + 'Length': wires[bundle]['length'], + 'Color': wires[bundle]['colors'][x], + 'Gauge': wires[bundle]['gauge'], + 'End 2': connector2, + 'Pin 2': connector2pins[x], + }) + + + + + #print(connection[1]) + for wire in wires: - wire_name = wire.get('name') - from_point = wire.get('from') - to_point = wire.get('to') + wire_name = wire + length = wires[wire]['length'] - wire_info.append({ - 'Wire Name': wire_name, - 'From': from_point, - 'To': to_point - }) # Create a DataFrame to display the data as a table - wire_df = pd.DataFrame(wire_info, columns=['Wire Name', 'From', 'To']) + wire_df = pd.DataFrame(wire_info, columns=['End 1', 'Pin 1', 'Length', 'Color', 'Gauge', 'End 2', 'Pin 2']) return wire_df # Path to your WireViz YML file -file_path = 'your_wireviz_file.yml' +file_path = 'wireviz\Choppy_IB_1X.yml' wire_table = parse_wireviz_yml(file_path) # Display the table -- cgit v1.2.3