-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask1.py
More file actions
28 lines (16 loc) · 766 Bytes
/
Task1.py
File metadata and controls
28 lines (16 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Program to concatenate two excel file into one
#importing all the libraries
import os
import pandas as pd
#The directory of the stored excel sheets should be same as the current directory
folder_path = '.\\Task1_ExcelSheet'
#Creating an empty dataframe
df = []
#Navigating through the for loop and checking conditions whether the extension is ".xlsx" or not
for file in os.listdir(folder_path):
if file.endswith('.xlsx'):
print('Loading file {0}...'.format(file))
df.append(pd.read_excel(os.path.join(folder_path, file)))
#Concatinating the files and naming the final sheet as Task1_ExcelSheet_Result.xlsx
df_master = pd.concat(df, axis=0)
df_master.to_excel('Task1_ExcelSheet_Result.xlsx', index=False)