python 获取excel文件的所有sheet名字

时间:2018-02-15 00:55:31   收藏:0   阅读:4851

当一个excel文件的sheet比较多时候, 这时候需要获取所有的sheet的名字. 

xl = pd.ExcelFile(foo.xls)

xl.sheet_names  # see all sheet names

xl.parse(sheet_name)  # read a specific sheet to DataFrame

 

也可以直接读取所有的sheet,  将sheetname设置为None.  这时候得到的是一个dict结果.

 df = pandas.read_excel("/yourPath/FileName.xlsx", None);

"df" are all sheets as a dictionary of DataFrames, you can verify it by run this:

df.keys()

原文:https://www.cnblogs.com/qingyuanjushi/p/8449151.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!