import pandas as pd
workbook_url = 'C:/file.xlsx'
df = pd.concat(pd.read_excel(workbook_url, sheet_name=None), ignore_index=True, sort=False)
Can someone help me concat all sheets from my Excel file, but excluding two Sheets called 'Main' and 'Info'?
In this case I don't want to manually specify all sheet names that I want to load, but in instead I want to specify the ones that I don't want to load.
Is that possible?
Thanks!
May be try this to see if that helps,
import pandas as pd
xl = pd.ExcelFile('test123.xlsx')
a=xl.sheet_names
print(a)# original sheet names list
exclusionlist=["Sheet1","Sheet4"]# exclusion list
for item in exclusionlist:
a.remove(item)
print(a)#now "a" have remaining sheetnames
workbook_url = 'test123.xlsx'
#df = pd.read_excel(workbook_url, sheet_name=a, ignore_index=True)
df = pd.concat(pd.read_excel(workbook_url, sheet_name=a), ignore_index=True, sort=False)
print(df)
#print(df.keys()
Best Regards,
Sandeep
GANGA SANDEEP KUMAR