Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dfList = []
- path = 'J:/TestDup'
- newpath = 'J:/TestDup/Test2'
- for fn in os.listdir(path):
- file = os.path.join(path, fn)
- if os.path.isfile(file):
- # Import the excel file and call it xlsx_file
- xlsx_file = pd.ExcelFile(file)
- # View the excel files sheet names
- xlsx_file.sheet_names
- # Load the xlsx files Data sheet as a dataframe
- df = xlsx_file.parse('Sheet1',header= None)
- df_NoHeader = df[2:]
- data = df_NoHeader
- # Save individual dataframe
- data.to_excel(os.path.join(newpath, fn))
- dfList.append(data)
- appended_data = pd.concat(dfList)
- appended_data.to_excel(os.path.join(newpath, 'master_data.xlsx'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement