diff --git a/sc200-html.py b/sc200-html.py new file mode 100755 index 0000000..1e797bd --- /dev/null +++ b/sc200-html.py @@ -0,0 +1,378 @@ +#!/usr/bin/python3 + +import sys +import csv +import re +import textwrap + +inFilePath = sys.argv[1] + +class MyDict(dict): + def __missing__(self, key): + return {} + +def Input(): + with open(inFilePath, 'r', newline='') as inFile: + csvReader = csv.DictReader(inFile) + + # print(csvReader) + + for row in csvReader: + Description = row['description'] + IP = row['ip address'] + District=re.split(r'[\d]+', Description)[0] + if District.endswith('S') and "-" not in Description: + District = District[:-1] + Segment=re.split(r'[\s-]+', Description)[0] + + if not Description: + continue + # print("""|%s|""" % Description) + + if District not in Devices.keys(): + Devices[District] = {} + Devices[District][Segment] = {} + elif Segment not in Devices[District].keys(): + Devices[District][Segment] = {} + + Devices[District][Segment][Description] = IP + inFile.close() + +def Output(): + for District in sorted(Devices.keys()): + print ("""\ +