From fbb56bade4d4ff03e66c3b8c217764588fb2dcd7 Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Sun, 16 Jun 2024 11:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EgenerateUsagedetail=E5=87=BD?= =?UTF-8?q?=E6=95=B0,=20=E6=A0=B9=E6=8D=AE=E6=9F=90=E4=B8=AA=E5=B0=8F?= =?UTF-8?q?=E9=97=B2=E5=AF=BC=E5=87=BA=E7=9A=84zip=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=AA=E4=BA=BA=E4=BD=BF=E7=94=A8=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v4/database_tools_2.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/工具v4/database_tools_2.py b/工具v4/database_tools_2.py index e04dd087..7b87d999 100644 --- a/工具v4/database_tools_2.py +++ b/工具v4/database_tools_2.py @@ -4,6 +4,7 @@ import numpy as np import pyperclip import mysql.connector import tqdm +import zipfile,shutil BuildFullScheme = { @@ -3298,6 +3299,32 @@ def findxiaobenIDs(jsonpath,grade = ""): #根据jsonpath中的校本材料获取 return jsonIDs +def generateUsagedetail(zipfilepath,tempdir,answersheetseekingpath,statsfilename,threshold,date): #根据zipfilepath文件路径, threshold最低提交比例阈值, date日期产生对应一张答题纸的使用记录 + try: + shutil.rmtree(tempdir) + except: + pass + makedir(tempdir) + # try: + xiaoxianpid = ParseZipname(zipfilepath) + paperinfo = FindPaper(xiaoxianpid, answersheetseekingpath) + if type(paperinfo) == bool: + print("!!!!!",zipfilepath) + return 1 + else: + gradename = paperinfo[1] + idlist = paperinfo[2] + excludejson = paperinfo[4] + print(paperinfo) + zf = zipfile.ZipFile(zipfilepath) + zf.extractall(tempdir) #解压zip文件中的所有内容到tempdir + statsfilepathlist = FindFile(tempdir,statsfilename) + validcols,marks = generateColIndexandMarks(statsfilepathlist,statsfilename,paperinfo) + dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],statsfilename)) + correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols]) + outputlist = CalculateDetailedUsages(xiaoxianpid,statsfilepathlist,statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date,exclude=RefineExclude(excludejson)) + return outputlist #返回由usages开始的使用记录列表 + if __name__ == "__main__": print("数据库工具, import用.") \ No newline at end of file