zoukankan      html  css  js  c++  java
  • Python Execl导入

    
    
    import xlrd

    from xlrd import open_workbook

    def
    getExeclInfo(filepath,colnameindex=0,by_index=0): data = xlrd.open_workbook(filepath) table = data.sheets()[by_index] # 行数 nrows = table.nrows # 列数 ncols = table.ncols colnames = table.row_values(colnameindex) list = [] for rownum in range(1,nrows): row = table.row_values(rownum) if row: app = {} for i in range(len(colnames)): app[colnames[i]] = row[i] list.append(app) return list
    数据插入
    def insertExeclInfo(list):
        session = db.session
        for dict in list:
            if list.index(dict) > 0:
                print(dict)
                try:
                    demo = models.Demo(id=dict['工号'],entrydate=dict['入职日期'],entryreasons=dict['入职原因'],RSscope=dict['人事范围'])
                    demotwo = models.DemoTwo(id = dict['工号'],surname = dict[''],name = dict[''],woman = dict[''],man = dict[''],birthdata = dict['出生日期'],birthcountry = dict['国籍'],maritalstatus = dict['婚姻状态'])
                    session.add(demotwo)
                    session.add(demo)
                except Exception as e:
                    return """<html><body><h1>数据插入异常</h1><p>Your chard could not
                     be charged. Please check the number and/or contact your credit card
                     company.</p></body></html>"""
        session.commit()
  • 相关阅读:
    JDBC连接MySQL并且查询操作。
    struts
    KMP 剪花布条hdoj2087
    线段树---敌兵布阵hdoj 1166
    设计模式----观察者模式
    线段树--hdoj1754
    ZOJ 2283 Challenge of Wisdom
    SGU 134 Centroid
    UVA 1637 Double Patience
    HDU 4389 X mod f(x)
  • 原文地址:https://www.cnblogs.com/Jonecmnn/p/7660950.html
Copyright © 2011-2022 走看看