The code below reads an xml file, it then runs a function and as the last step it parses the data into an xlsx file.
if __name__ == '__main__':
xml = XMLParser.parse(r'./work.xml')
xml.recurs_collect(opdata_collector)
df.to_excel("./output.xlsx")
If I want to include a second xml files, I have to basically copy and paste the code and write the name of the new xml file.
if __name__ == '__main__':
xml = XMLParser.parse(r'./work.xml')
xml.recurs_collect(opdata_collector)
xml = XMLParser.parse(r'./work2.xml')
xml.recurs_collect(opdata_collector)
df.to_excel("./output.xlsx")
I have tried the following but without success
directory = 'C:\Users\342\Desktop\num\docs\test'
for filename in os.listdir(directory):
if filename.endswith(".xml"):
xml.recurs_collect(opdata_collector)
df.to_excel("./output.xlsx")
continue
else:
continue