本文介绍了如何用Python从我的XLS文件中读取特定的工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
到目前为止,我可以阅读Excel文件的所有工作表。
e.msgbox("select Excel File") updated_deleted_xls = e.fileopenbox() book = xlrd.open_workbook(updated_deleted_xls, formatting_info=True) openfile = e.fileopenbox() for sheet in book.sheets(): for row in range(sheet.nrows): for col in range(sheet.ncols): thecell = sheet.cell(row, 0) xfx = sheet.cell_xf_index(row, 0) xf = book.xf_list[xfx] 推荐答案如果从桌面或命令行打开编辑器,则在尝试读取文件时必须指定文件路径:
import pandas as pd df = pd.read_excel(r'File path', sheet_name='Sheet name')或者,如果您在文件目录中打开您的编辑器,则可以使用Panda库直接读取
import pandas as pd df = pd.read_excel('KPMG_VI_New_raw_data_update_final.xlsx', sheet_name='Title Sheet') df1 = pd.read_excel('KPMG_VI_New_raw_data_update_final.xlsx',sheet_name='Transactions') df2 = pd.read_excel('KPMG_VI_New_raw_data_update_final.xlsx', sheet_name='NewCustomerList') df3 = pd.read_excel('KPMG_VI_New_raw_data_update_final.xlsx', sheet_name='CustomerDemographic') df4 = pd.read_excel('KPMG_VI_New_raw_data_update_final.xlsx', sheet_name='CustomerAddress')更多推荐
如何用Python从我的XLS文件中读取特定的工作表
发布评论