修正分年级数据导入中的一个日期bug并增加了全卷自动对应题号功能
This commit is contained in:
parent
e69be89dc1
commit
2ab2e98655
|
|
@ -2,7 +2,7 @@
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": 8,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
"import pandas as pd\n",
|
"import pandas as pd\n",
|
||||||
"from pathlib import Path\n",
|
"from pathlib import Path\n",
|
||||||
"\n",
|
"\n",
|
||||||
"#设置工作目录, 要求工作目录中恰有一个.tex文件和一个.zip文件,其余不论\n",
|
"#设置工作目录, 要求工作目录中恰有一些.tex(.txt)文件和一些.zip文件,对应的文件名需相同, 其余不论\n",
|
||||||
"filepath = \"数据导入作业文件\"\n",
|
"filepath = \"数据导入作业文件\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# date = str(time.localtime().tm_year)+str(time.localtime().tm_mon).zfill(2)+str(time.localtime().tm_mday).zfill(2)\n",
|
"# date = str(time.localtime().tm_year)+str(time.localtime().tm_mon).zfill(2)+str(time.localtime().tm_mday).zfill(2)\n",
|
||||||
|
|
@ -29,6 +29,10 @@
|
||||||
" #生成文件名tex_file和zip_file\n",
|
" #生成文件名tex_file和zip_file\n",
|
||||||
" zip_file, tex_file = fp\n",
|
" zip_file, tex_file = fp\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
" newdate = input(os.path.split(zip_file)[-1][:4]+\"使用日期(\"+date+\", 不变按回车, 要变化仅需输入最后几位改变的数字):\")\n",
|
||||||
|
" newdate = \"\".join(re.findall(r\"\\d\",newdate))\n",
|
||||||
|
" change_len = len(newdate)\n",
|
||||||
|
" date = date[:8-change_len]+newdate\n",
|
||||||
"\n",
|
"\n",
|
||||||
" #获得题号数据,保存在problems_list中\n",
|
" #获得题号数据,保存在problems_list中\n",
|
||||||
" with open(tex_file,\"r\",encoding = \"utf8\") as f:\n",
|
" with open(tex_file,\"r\",encoding = \"utf8\") as f:\n",
|
||||||
|
|
@ -47,12 +51,20 @@
|
||||||
" extractedpath.rename(\"临时文件/statsfile.xlsx\")\n",
|
" extractedpath.rename(\"临时文件/statsfile.xlsx\")\n",
|
||||||
" df = pd.read_excel(\"临时文件/statsfile.xlsx\")\n",
|
" df = pd.read_excel(\"临时文件/statsfile.xlsx\")\n",
|
||||||
" problems_indexes = list(df[df.columns[0]][2:])\n",
|
" problems_indexes = list(df[df.columns[0]][2:])\n",
|
||||||
|
" autofill = False\n",
|
||||||
" for p in problems_indexes:\n",
|
" for p in problems_indexes:\n",
|
||||||
" t = input(os.path.split(zip_file)[-1][:4]+\"答题纸区域\"+p+\"的题号为(1-\"+str(len(problems_list))+\", a为自动对应点前的题号):\")\n",
|
" if not autofill:\n",
|
||||||
" if t.upper() == \"A\":\n",
|
" t = input(os.path.split(zip_file)[-1][:4]+\"答题纸区域\"+p+\"的题号为(1-\"+str(len(problems_list))+\", a为自动对应点前的题号, u为之后完全自动对应):\")\n",
|
||||||
|
" if t.upper() == \"A\":\n",
|
||||||
|
" correspondence_dict[p] = problems_list[int(re.findall(r\"([\\d]+?)\\.\",p)[0])-1]\n",
|
||||||
|
" elif t.upper() == \"U\":\n",
|
||||||
|
" correspondence_dict[p] = problems_list[int(re.findall(r\"([\\d]+?)\\.\",p)[0])-1]\n",
|
||||||
|
" autofill = True\n",
|
||||||
|
" elif not (int(t)<1 or int(t)>len(problems_list)):\n",
|
||||||
|
" correspondence_dict[p] = problems_list[int(t)-1]\n",
|
||||||
|
" else:\n",
|
||||||
" correspondence_dict[p] = problems_list[int(re.findall(r\"([\\d]+?)\\.\",p)[0])-1]\n",
|
" correspondence_dict[p] = problems_list[int(re.findall(r\"([\\d]+?)\\.\",p)[0])-1]\n",
|
||||||
" elif not (int(t)<1 or int(t)>len(problems_list)):\n",
|
"\n",
|
||||||
" correspondence_dict[p] = problems_list[int(t)-1] \n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
@ -85,67 +97,6 @@
|
||||||
"zf.close()\n",
|
"zf.close()\n",
|
||||||
"\n"
|
"\n"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 8,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"''"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 8,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"t"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 6,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"('数据导入作业文件', 'sj02.zip')"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 6,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"os.path.split(zip_file)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
|
||||||
Reference in New Issue