Combine multiple excel files into One

From rbachwiki
Revision as of 22:16, 2 September 2020 by Bacchas (talk | contribs) (Created page with "<pre> import glob import os import pandas as pd file = input('File Path: ') pth = os.path.dirname(file) extension = os.path.splitext(file)[1] print(pth) files = glob.glob(os.p...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
import glob
import os
import pandas as pd
file = input('File Path: ')
pth = os.path.dirname(file)
extension = os.path.splitext(file)[1]
print(pth)
files = glob.glob(os.path.join(pth, '*.xls*'))
files

df = pd.DataFrame()

for f in files:
    data = pd.read_excel(f)
    df = df.append(data)

set(df['PDF Filename'])
df.to_excel("combined_files.xlsx")

df.shape

Back To Top - Main Category/ Excel Category