查找目标文件夹内所有的Excel文件,按月份统计相关业务量,并输出到文本文档。
import time
import os
import xlrd
import copy
import pathlib
import datetime
import sys
import collections
def getusefile():
#查当前目录下所有xls xlsx文件,返回文件名列表
usefile=[]
excelfile=sorted(pathlib.Path('.').glob('*.xls*'))
usefile=[str(tpfile) for tpfile in excelfile]
return copy.deepcopy(usefile)
def rdusefile(fileName):
#读一个文件,并在文件单元格中查找目标数据,如果找到就返回文件名及数据
data=xlrd.open_workbook(fileName) #打开当前目录下名为 fileName 的文档
worksheets = data.sheet_names(