zoukankan      html  css  js  c++  java
  • python合并表格sheets

    import xlrd
    import pandas as pd
    from pandas import DataFrame

    DATA_DIR = r"D:UsersFengZH2Desktopdata工作簿28.xlsx"
    #excel_name = '%s2017.xls' % DATA_DIR
    wb = xlrd.open_workbook(DATA_DIR)
    #DATA_DIR = r'C:UsersAdministratorDesktop'
    #excel_name = r'C:UsersAdministratorDesktop est.xlsx'
    #wb = pd.read_excel(excel_name)
    print(wb)

    # 获取workbook中所有的表格
    sheets = wb.sheet_names()
    print(sheets)

    # 循环遍历所有sheet
    df_28 = DataFrame()
    for i in range(len(sheets)):
    # skiprows=2 忽略前两行
    df = pd.read_excel(DATA_DIR, sheet_name=i, skiprows=0, index=False, encoding='utf8')
    df_28 = df_28.append(df)
    # 去除缺省值
    #df_28 = df_28.dropna()
    #df_28 = df_28.reset_index(drop=True)
    print(df_28)

    df_28.to_excel(r'D:UsersFengZH2Desktopdata est1.xlsx')

  • 相关阅读:
    day89
    day88
    day87
    day86
    day85
    day84
    day83
    Maven仓库汇总
    [转载]AngularJS入门教程04:双向绑定
    [转载]AngularJS入门教程03:迭代器
  • 原文地址:https://www.cnblogs.com/yukit/p/14072524.html
Copyright © 2011-2022 走看看