更新小闲获取数据new, 未结束
This commit is contained in:
parent
cd51a50f99
commit
de4fabb00e
|
|
@ -1,4 +1,5 @@
|
||||||
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog, QTableWidgetItem
|
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog, QTableWidgetItem
|
||||||
|
from PySide6.QtGui import QColor
|
||||||
from Ui_获取小闲平台使用数据new import Ui_Form
|
from Ui_获取小闲平台使用数据new import Ui_Form
|
||||||
from database_tools import *
|
from database_tools import *
|
||||||
|
|
||||||
|
|
@ -63,8 +64,7 @@ class MyWindow(QWidget,Ui_Form):
|
||||||
self.execmultifile()
|
self.execmultifile()
|
||||||
|
|
||||||
def execmultifile(self): #待修改
|
def execmultifile(self): #待修改
|
||||||
directory = self.label_filepath.text()
|
files = self.filelist
|
||||||
files = [f for f in os.listdir(directory) if ".zip" in f]
|
|
||||||
datedfiles = []
|
datedfiles = []
|
||||||
tempdir = "临时文件/zips"
|
tempdir = "临时文件/zips"
|
||||||
statsfilename = "小题分_按学号(数学).xlsx"
|
statsfilename = "小题分_按学号(数学).xlsx"
|
||||||
|
|
@ -113,51 +113,53 @@ class MyWindow(QWidget,Ui_Form):
|
||||||
|
|
||||||
|
|
||||||
def execsinglefile(self): #待修改
|
def execsinglefile(self): #待修改
|
||||||
date = self.lineEdit_date.text()
|
self.tableWidget.clearSelection()
|
||||||
|
self.tableWidget.item(0,2).setBackground(QColor("transparent"))
|
||||||
|
date = self.tableWidget.item(0,2).text()
|
||||||
threshold = float(self.lineEdit_threshold.text())
|
threshold = float(self.lineEdit_threshold.text())
|
||||||
if not len(date.strip()) == 8:
|
if not len(date.strip()) == 8:
|
||||||
self.lineEdit_date.setText("日期格式有误")
|
self.tableWidget.item(0,2).setBackground(QColor("red"))
|
||||||
elif not threshold >= 0 or not threshold <= 1:
|
elif not threshold >= 0 or not threshold <= 1:
|
||||||
self.lineEdit_threshold.setText("阈值有误")
|
self.lineEdit_threshold.setText("阈值有误")
|
||||||
else:
|
# else:
|
||||||
tempdir = "临时文件/zips"
|
# tempdir = "临时文件/zips"
|
||||||
statsfilename = "小题分_按学号(数学).xlsx"
|
# statsfilename = "小题分_按学号(数学).xlsx"
|
||||||
answersheetseekingpath = "../备课组"
|
# answersheetseekingpath = "../备课组"
|
||||||
try:
|
# try:
|
||||||
shutil.rmtree(tempdir)
|
# shutil.rmtree(tempdir)
|
||||||
except:
|
# except:
|
||||||
pass
|
# pass
|
||||||
makedir(tempdir)
|
# makedir(tempdir)
|
||||||
xiaoxianpid = ParseZipname(self.zipfilepath)
|
# xiaoxianpid = ParseZipname(self.zipfilepath)
|
||||||
paperinfo = FindPaper(xiaoxianpid, answersheetseekingpath)
|
# paperinfo = FindPaper(xiaoxianpid, answersheetseekingpath)
|
||||||
gradename = paperinfo[1]
|
# gradename = paperinfo[1]
|
||||||
idlist = paperinfo[2]
|
# idlist = paperinfo[2]
|
||||||
|
|
||||||
zf = zipfile.ZipFile(self.zipfilepath)
|
# zf = zipfile.ZipFile(self.zipfilepath)
|
||||||
zf.extractall(tempdir) #解压zip文件中的所有内容到tempdir
|
# zf.extractall(tempdir) #解压zip文件中的所有内容到tempdir
|
||||||
|
|
||||||
# papertype = CheckPaperType(tempdir,statsfilename)
|
# # papertype = CheckPaperType(tempdir,statsfilename)
|
||||||
statsfilepathlist = FindFile(tempdir,statsfilename)
|
# statsfilepathlist = FindFile(tempdir,statsfilename)
|
||||||
validcols,marks = generateColIndexandMarks(statsfilepathlist,statsfilename,paperinfo)
|
# validcols,marks = generateColIndexandMarks(statsfilepathlist,statsfilename,paperinfo)
|
||||||
dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],statsfilename))
|
# dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],statsfilename))
|
||||||
correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols])
|
# correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols])
|
||||||
output = CalculateUsages(statsfilepathlist,statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date)
|
# output = CalculateUsages(statsfilepathlist,statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date)
|
||||||
if CheckUsagesValidity(output) == 0:
|
# if CheckUsagesValidity(output) == 0:
|
||||||
if not self.checkBox_appendflag.isChecked():
|
# if not self.checkBox_appendflag.isChecked():
|
||||||
SaveTextFile(output,"文本文件/metadata.txt")
|
# SaveTextFile(output,"文本文件/metadata.txt")
|
||||||
print("数据文件已输出至metadata.txt")
|
# print("数据文件已输出至metadata.txt")
|
||||||
self.label_filepath.setText("数据文件已输出至metadata.txt")
|
# self.label_filepath.setText("数据文件已输出至metadata.txt")
|
||||||
os.system("code 文本文件/metadata.txt")
|
# os.system("code 文本文件/metadata.txt")
|
||||||
else:
|
# else:
|
||||||
AppendTextFile("\n\n"+output,"文本文件/metadata.txt")
|
# AppendTextFile("\n\n"+output,"文本文件/metadata.txt")
|
||||||
print("数据文件已添加至metadata.txt")
|
# print("数据文件已添加至metadata.txt")
|
||||||
self.label_filepath.setText("数据文件已添加至metadata.txt")
|
# self.label_filepath.setText("数据文件已添加至metadata.txt")
|
||||||
os.system("code 文本文件/metadata.txt")
|
# os.system("code 文本文件/metadata.txt")
|
||||||
|
|
||||||
|
|
||||||
else:
|
# else:
|
||||||
print("数据有误, 可能需要检查每一题的满分数据")
|
# print("数据有误, 可能需要检查每一题的满分数据")
|
||||||
self.label_filepath.setText("数据有误, 可能需要检查每一题的满分数据")
|
# self.label_filepath.setText("数据有误, 可能需要检查每一题的满分数据")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue