diff options
author | Joshua Drake <joshua.ellis.drake@okstate.edu> | 2024-11-05 17:11:43 -0600 |
---|---|---|
committer | Joshua Drake <joshua.ellis.drake@okstate.edu> | 2024-11-05 17:11:43 -0600 |
commit | 246447d7155b7b04bb9d477ecccc860dd79bdd6a (patch) | |
tree | 29ca65433f79121cbd1aa249a8af0464d8cfe0cc /tableconversion.py | |
parent | 1f55b201683159c209a95e973a370ccb325d4dca (diff) |
Added mechanism for accounting for singles. Need to finish shielding, and splicing issues.
Diffstat (limited to 'tableconversion.py')
-rw-r--r-- | tableconversion.py | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/tableconversion.py b/tableconversion.py index ef81240..c69ac71 100644 --- a/tableconversion.py +++ b/tableconversion.py @@ -6,43 +6,59 @@ def parse_wireviz_yml(file_path): # Load the WireViz YML file with open(file_path, 'r') as file: data = yaml.safe_load(file) - + idcount = 0 wires = data['cables'] connectors = data['connectors'] connections = data['connections'] + connectorlist = [] + for connector in data['connectors']: + connectorlist.append(connector) + print(connectorlist) wire_info = [] for connection in connections: connectorwpin = str(connection[0]) connector = connectorwpin[2:connectorwpin.find("':")] + #currently skipping all abnormal conditions + if connectorlist.count(connector) < 1: + continue connectorpins = connectorwpin[connectorwpin.find(" [")+2:connectorwpin.rfind("]}")].strip(" ").split(",") connectorpinsadjusted = [] for pins in connectorpins: - if pins.count("-") > 0: + if str(pins).count("-") > 0: pinrange = pins.strip("' ").split("-") + print(pinrange) for x in range(int(pinrange[0]),int(pinrange[1])+1): connectorpinsadjusted.append(x) else: - connectorpinsadjusted = connectorpins + connectorpinsadjusted.append(pins) + print(connectorpinsadjusted) connectorwires = str(connection[1]) bundle = connectorwires[2:connectorwires.find("':")] bundlewires = connectorwires[connectorwires.find(" [")+2:connectorwires.rfind("]}")].split(",") + + connector2pinsadjusted = [] + idcount=idcount+1 if len(connection) > 2: connector2wpin = str(connection[2]) connector2 = connector2wpin[2:connector2wpin.find("':")] connector2pins = connector2wpin[connector2wpin.find(" [")+2:connector2wpin.rfind("]}")].split(",") - print(connector2pins) - connector2pinsadjusted = [] - for pins in connector2pins: - if pins.count("-") > 0: - pinrange = pins.strip("' ").split("-") - for x in range(int(pinrange[0]),int(pinrange[1])+1): - connector2pinsadjusted.append(x) - else: - connector2pinsadjusted = connector2pins - print(connector2pinsadjusted) + + for pins in connector2pins: + if pins.count("-") > 0: + pinrange = pins.strip("' ").split("-") + for x in range(int(pinrange[0]),int(pinrange[1])+1): + connector2pinsadjusted.append(x) + else: + connector2pinsadjusted = connector2pins for x in range(0,len(connectorpinsadjusted)): + ident = str(ord(connector[0]))+str(ord(str(connectorpinsadjusted[x])[0]))+str(ord(wires[bundle]['colors'][x][0]))+str(idcount) + ident = ident.strip(" ") + notes = "none" + if str(wires[bundle]).find("'notes':") > 0: + notes = wires[bundle]['notes'] wire_info.append({ + 'Identifier': ident, 'End 1': connector, 'Pin 1': connectorpinsadjusted[x], 'Length': wires[bundle]['length'], @@ -50,26 +66,38 @@ def parse_wireviz_yml(file_path): 'Gauge': wires[bundle]['gauge'], 'End 2': connector2, 'Pin 2': connector2pinsadjusted[x], + 'Notes': notes, + }) + else: + for x in range(0,len(connectorpinsadjusted)): + ident = str(ord(connector[0]))+str(ord(str(connectorpinsadjusted[x])[0]))+str(ord(wires[bundle]['colors'][x][0]))+str(idcount) + ident = ident.strip(" ") + notes = "none" + if str(wires[bundle]).find("'notes':") > 0: + notes = wires[bundle]['notes'] + wire_info.append({ + 'Identifier': ident, + 'End 1': connector, + 'Pin 1': connectorpinsadjusted[x], + 'Length': wires[bundle]['length'], + 'Color': wires[bundle]['colors'][x], + 'Gauge': wires[bundle]['gauge'], + 'End 2': "----", + 'Pin 2': "----", + 'Notes': notes, }) - - #print(connection[1]) - - - for wire in wires: - wire_name = wire - length = wires[wire]['length'] - - # Create a DataFrame to display the data as a table - wire_df = pd.DataFrame(wire_info, columns=['End 1', 'Pin 1', 'Length', 'Color', 'Gauge', 'End 2', 'Pin 2']) + wire_df = pd.DataFrame(wire_info, columns=['Identifier','End 1', 'Pin 1', 'Length', 'Color', 'Gauge', 'End 2', 'Pin 2', 'Notes']) return wire_df # Path to your WireViz YML file -file_path = 'wireviz/Choppy_IB_PPS_main.yml' +file_path = 'wireviz/Choppy_IB_CEX.yml' wire_table = parse_wireviz_yml(file_path) # Display the table print(wire_table) +outputfile = file_path[:-4]+".csv" +wire_table.to_csv(outputfile) |