Nov-05-2022, 08:27 PM
I have the following working code which amalgamates excel file data into one Excel file. How do I amend the code so that I do not have an index column on the first column?
import pandas as pd
import os
input_location = "D:/Power BI & Python/Test - Input File/"
output_location = "D:/Power BI & Python/Test - Output File/"
output_file = "Consolidated.xlsx"
excelfiles = os.listdir(input_location)
excelfilesdf = pd.DataFrame()
for excelfile in excelfiles:
if excelfile.endswith('xlsx'):
dfFilename = {'sales_id':excelfile} # to place the MS Excel filename in the first column, use the first column header
df = pd.read_excel(input_location + excelfile)
excelfilesdf = excelfilesdf.append(dfFilename, ignore_index=True)
excelfilesdf = excelfilesdf.append(df)
excelfilesdf.to_excel(output_location + output_file)
