Skip to content

Instantly share code, notes, and snippets.

@datagy
Last active September 22, 2022 22:47
Show Gist options
  • Select an option

  • Save datagy/329adff704eca82ad16e70c6f0a8100d to your computer and use it in GitHub Desktop.

Select an option

Save datagy/329adff704eca82ad16e70c6f0a8100d to your computer and use it in GitHub Desktop.
Read Multiple Excel Files at Once
import pandas as pd
import os
# Create list of files
file_path = '/Desktop/Files/'
files = [os.path.join(file_path, file) for file in os.listdir(file_path)]
# Join DataFrames Using pd.concat()
df = pd.concat([pd.read_excel(file) for file in files], ignore_index=True)
print(df.head())
# Returns:
# Day Month Year Name Amount
# 0 1 2 2023 Nik 117
# 1 2 2 2023 Jane 103
# 2 3 2 2023 Kate 135
# 3 4 2 2023 Evan 195
# 4 5 2 2023 Nik 178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment