Here's my code :
import glob
import pandas
import os
os.chdir("/filepath")
extension = 'xlsx'
all_filenames = [i for i in glob.glob('*.{}'.format(extension))]
combined = pd.concat([pd.read_excel(f) for f in all_filenames ])
combined.to_excel("data.xlsx", header=False, index=False)
My question is : How to delete all th files in the folder except the last one data.xslx
.
Like that, I always have the last file and if I want to concat again, it just concat the new files with one file, the one who was concatened before. So I avoid duplicates.