I have a lot excel files, all with the same format and I just want to make one big file with the concatenation of all the others.
For the moment I tried to use pandas in a simple for loop with only two files and it worked correctly but in my final file the data from my two files are separated by an empty row and I can’t understand why.
import pandas as pd
import glob as glob
listExcel=glob.glob("/content/*.xlsx")
AllData=pd.DataFrame()
for f in listExcel:
df=pd.read_excel(f)
AllData=pd.concat([AllData,df])
AllData.to_excel("AllData.xlsx")
I tried to check size of my files with df.shape and AllData.shape and here it also seems correct AllData size is exactly the size of the two concatenated files. I’m a panda beginner and I can’t understand where this empty line is coming from…
Thomas Moreau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.