#!/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 ("""\ """) # print ("""\ # # # """) print ("""\ """) def Header(): print (r""" SC200 Management Interface

SC200 Management Interface

Expand All Collapse All