zoukankan      html  css  js  c++  java
  • 统计excel表格的py

    # -*- coding: utf-8 -*-

    import xlrd
    import xlwt
    import os
    import sys
    reload(sys)
    sys.setdefaultencoding('utf8')
    xlrd.Book.encoding = "gbk"

    type=sys.getfilesystemencoding()
    s = os.sep
    counter = 0
    chipan = "e:"
    wenjianjia = "hh"
    wenjianjia = wenjianjia.decode('utf-8').encode(type)
    root = chipan + s + wenjianjia + s
    for root,dirs,files in os.walk(root):
        for dir in dirs:
            os.path.join(root,dir).decode('gbk').encode('utf-8')
        for file in files:
            filename = os.path.join(root,file).decode('gbk').encode('utf-8')
            if (os.path.splitext(filename)[1] == '.xls')or(os.path.splitext(filename)[1] == '.xlsx'):
                try:
                    print filename.decode('utf-8').encode(type)
                    uipath = unicode(filename, "utf8")
                    data = xlrd.open_workbook(uipath)
                    table = data.sheets()[0]
                    assert isinstance(table.nrows, object)
                    nrows = table.nrows
                    counter += nrows
                    print counter
                except:
                    print "error"
               

  • 相关阅读:
    gil
    异步
    字符串 最长回文字串
    字符串 最长公共前缀
    数组 合并区间
    python 排序
    2021.9.3 阿里笔试AK贴
    SIP协议详解
    fiddler抓包各字段的含义
    常见的HTTP状态码列表
  • 原文地址:https://www.cnblogs.com/wj2ge/p/6412826.html
Copyright © 2011-2022 走看看