reading multiple tabs from excel in different dataframes

前端 未结 2 1083
梦毁少年i
梦毁少年i 2020-12-30 16:21

I am trying to read multiple tabs in spreadsheet to different dataframes and once all tabs with data are over the program should stop.

For first part I am looking to

2条回答
  •  被撕碎了的回忆
    2020-12-30 17:04

    This will read all sheets and make a dictionary of dataframes:

    xl = pd.read_excel('Unique.xlsx', sheet_name=None)
    

    To get specific sheets, you could do:

    xl_dict = {}
    sheetname_list = ['blah1', 'blah2', 'blah3']
    for sheet in sheetname_list:
        xl_dict[sheet] = pd.read_excel('Unique.xlsx', sheet_name=sheet)
    

    or:

    xl = pd.read_excel('Unique.xlsx', sheet_name=sheetname_list)
    

提交回复
热议问题