I have a folder with >1000 .xlsx-files containing data. I want to merge all that data into one sheet to process it further. Every .xlsx-file has 4 sheets called (Sheet 1, Sheet 2, Sheet 3 and Data). As the Excel-files always evolve, the sheet Data is always updated to the newest version. Reason behind is that for example when we change the layout, all data-sheets are identical to process. The data-sheet points to the other sheets in order to summarize the needed data.
Before starting to merge all the data, I want to update to the latest version of the data-sheet. For this I have a Template.xlsx in which there is a data-sheet. I have this code:
WorkbookTemplate=openpyxl.load_workbook(Template.xlsx)
if "Data" in WorkbookTemplate.sheetnames:
WorkSheetTemplate=WorkbookTemplate["Data"]
My problem is that my python script needs to run in UTF-8. The "Data"-sheet in the template cannot be found since, I have always the UTF-8 prefix in the sheetnames:
print(str(WorkbookTemplate.sheetnames))
which gives me:
[u'Sheet 1', u'Sheet 2', u'Sheet 3', u'data']
How can I overcome this situation, so that the "Data"-Worksheet is found?
As answered by Charlie Clark: the sheetnames are case sensitive! This solved the issue.