Skip to content

Instantly share code, notes, and snippets.

@avoajaugochukwu
Created July 9, 2020 07:25
Show Gist options
  • Save avoajaugochukwu/b2319ad88965780b0ce0d85a574e6fa4 to your computer and use it in GitHub Desktop.
Save avoajaugochukwu/b2319ad88965780b0ce0d85a574e6fa4 to your computer and use it in GitHub Desktop.
import os
import glob
import pandas as pd
if os.path.exists('output.xlsx'):
os.remove('output.xlsx')
all_excel_files = [i for i in glob.glob('*.xlsx')]
holder_list = list()
for i in range(len(all_excel_files)):
cfile = pd.read_excel(all_excel_files[i])
cfile.insert(0, "file_name", all_excel_files[i])
holder_list.append(cfile)
df = pd.concat(holder_list)
df.to_excel('output.xlsx', index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment