From 4759c20103e20ff2737e9fcd8b3fbe660717469f Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Tue, 18 Jun 2024 06:55:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=B0=8F=E9=97=B2=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E7=BA=B8=E6=9C=89=E6=95=88=E5=88=97=E7=9A=84=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E6=94=B9=E8=BF=9B,=20=E7=8E=B0=E5=B7=B2=E8=83=BD?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E5=A4=A7=E5=9E=8B=E8=80=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v4/database_tools_2.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/工具v4/database_tools_2.py b/工具v4/database_tools_2.py index de9e4a12..3d0dcdf8 100644 --- a/工具v4/database_tools_2.py +++ b/工具v4/database_tools_2.py @@ -2732,19 +2732,22 @@ def CheckPaperType(filepath,filename): #根据filepath(通常是小闲的zip解 def generateColIndexandMarks(filepath,statsfilename,paperinfo): #根据filepath(是一个有statsfilename的文件夹列表)中第一个路径中的数据文件, statsfilename数据文件名, 及paperinfo(FindPaper返回的结果)寻找excel文件中有效的列的位置和相应的满分分数 dir = filepath[0] dfcurrent = pd.read_excel(os.path.join(dir,statsfilename)) - validcols = [] + excludecols = [] for i in range(len(dfcurrent.columns)): colname = str(dfcurrent.iloc[1,i]) - if ("单选" in colname or "多选" in colname or "填空" in colname or "主观" in colname or "步" in colname ) and re.findall("[ABCD]",colname) == []: - validcols.append(i) - for col in range(len(validcols)-1,-1,-1): - colname = str(dfcurrent.iloc[1,validcols[col]]) - if "主观" in colname: - colname_main = re.findall(r"^([\d\.]*)[\($]",colname[2:])[0] - t = [dfcurrent.iloc[1,c] for c in validcols[col+1:]] - t = str(t) - if colname_main in t: - validcols.pop(col) + if re.findall("[A-Z]",colname) != []: + excludecols.append(i) + validcoldict = {} + for i in range(len(dfcurrent.columns)): + colname = str(dfcurrent.iloc[1,i]) + digname = re.findall(r"[\d\.]+",colname) + if len(digname) > 0 and not i in excludecols: + if not i-1 in validcoldict or not validcoldict[i-1] in digname[0]: + validcoldict[i] = digname[0] + else: + validcoldict.pop(i-1) + validcoldict[i] = digname[0] + validcols = list(validcoldict.keys()) if paperinfo[3] == []: marks = [1] * len(validcols) else: