I have around 50 excel files & I want to import to dataframe and merge all files into single dataframe. But some file has 3 some are 4 columns. Every file as different columns in different order.
Total distinct column from all the files: 5 i.e col1, col2, col3, col4, col5
I know how to import but while appending facing issue.
Script:
dfAll = pd.DataFrame(columns=['col1', 'col2', 'col3', 'col4', 'col5')]
df= pd.read_excel('FilePath', sheetname='data1') # contains 3 columns i.e col1, col2, col5
columnsOFdf = df.columns
dfAll[columnsOFdf] = dfAll.append(df)
but its giving error "ValueError: Columns must be same length as key"
I want to append df['col1','col2','col5'] data to dfAll['col1','col2','col5']
Please help on this issue.