How to add text files to excel sheet

Adding all ASA firewall configuration files into a excel spreadsheet to compare all configurations for auditing

I have written a code to put all text files into a single spreadsheet. This more useful for comparing configurations for network devices one to one from all three layers access, distribution and core. With this few lines of code you can automate the process of manually adding all the text files one after the other into spreadsheet and start auditing them. This helped me a lot in my profession work for auditing all network device configurations switches, routers and firewalls in WAPs especially for Cisco devices, as IOS and ASA OS configuration is easy to ready and compare. Other vendors like Juniper, Palo Alto or check point does have similar OS, but them can generate running configuration in XML formate. For firewall auditing purpose you can use this to compare and retire all security policies. “Some times old method is best to do for perfection” .

Code:

import glob, xlsxwriter

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

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

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