Moving multiple files into single Microsoft excel workbook, to perform auditing in conventional method.

Auditing network devices configuration is tough if nodes count is in large number. Sometimes because of standard procedures we have to follow conventional method to audit configurations of network devices including routers, switches and firewalls. Out of which we use spreadsheets to do compare configurations side by side and that’s really hell of a pain. even moving 10’s and 100’s of configs files to one excel spreadsheet. To move config files to excel, if can you spare couple of mins on python script that should save a lot of time. So, below is the script that i have used at my work to move all text files into a single excel file. Library i used for excel handling is xlsxwriter

import glob, xlsxwriter

workbook = xlsxwriter.Workbook('Example2.xlsx')
worksheet = workbook.add_worksheet()

fileslist = []
for file in glob.glob("C:/Users/sahithpixels/Documents/SDN/*"):
    a = file.strip('\n')
#    print(a)
row = 0
column = 0

filedata = []
for line in fileslist:
    row = 0
    with open(line, 'r') as inputfile:
        f ='\n\n')
        x = f.split('\n\n')
        for line2 in x:
            worksheet.write_string(row, column,line2)
            row += 1
    column += 1


Welcome to Typer

Brief and amiable onboarding is the first thing a new user sees in the theme.
Join Typer
Registration is closed.