This commit is contained in:
512song committed 2023-04-26 10:09:26 +00:00
1 parent 60cd4d2643
commit d5af3bcb91
6 files changed
+896 -218

No files matched your search

+305
View File
@@ -0,0 +1,305 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "d4d999fe-4890-4a14-b1e8-52dbd6d42e73",
"metadata": {},
"source": [
"## 导入人员信息"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "3154fc8c-0e91-4cda-ba75-666dc7bbb34d",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-26T02:09:17.305567Z",
"iopub.status.busy": "2023-04-26T02:09:17.304661Z",
"iopub.status.idle": "2023-04-26T02:09:17.783758Z",
"shell.execute_reply": "2023-04-26T02:09:17.782874Z",
"shell.execute_reply.started": "2023-04-26T02:09:17.305525Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/student_20140922长炼医院监测花名册.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,1).value is not None:\n",
" code = int(sheet.cell(n, 4).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 6).value\n",
" if int(sheet.cell(n, 7).value) ==1:\n",
" sex = '男'\n",
" else:\n",
" sex = '女'\n",
" dict1['sex'] = sex\n",
" birth = str(sheet.cell(n, 8).value).split()[0]\n",
" dict1['birth'] = birth\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" person[code] = dict1\n",
"filename = 'data/长炼医院人员名单.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "96d5b4bd-4198-4725-9005-070ac4e4f324",
"metadata": {},
"source": [
"## 每日成绩导入"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "4b52477e-926a-44b5-b8a0-20bff98d101d",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-26T02:03:49.859631Z",
"iopub.status.busy": "2023-04-26T02:03:49.858701Z",
"iopub.status.idle": "2023-04-26T02:03:49.891420Z",
"shell.execute_reply": "2023-04-26T02:03:49.890351Z",
"shell.execute_reply.started": "2023-04-26T02:03:49.859588Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6\n",
"6\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = '../item.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"for k,v in dict1.items():\n",
" item[k] = v\n",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/长炼医院人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"rq = '20230425'\n",
"filename = f'data/places_result_{rq}.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n",
"#print(list1)\n",
"for result in list1:\n",
" user = str(result[2])\n",
" if user in dict1.keys(): \n",
" m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n",
"\n",
"filename = f'data/result_长炼医院({rq}).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "033cc564-4aa9-4e88-b38b-ec62a02b1661",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = '../item.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"for k,v in dict1.items():\n",
" item[k] = v\n",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/燕山石化人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"rq = '20230425'\n",
"filename = f'data/places_result_{rq}.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n",
"#print(list1)\n",
"for result in list1:\n",
" user = str(result[2])\n",
" if user in dict1.keys(): \n",
" m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n",
"filename = 'data/result_长炼医院.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"for k in re_ta.keys():\n",
" if k in dict2.keys():\n",
" print(k,dict2[k]['name'],'已测试!')\n",
"for k, v in re_ta.items():\n",
" if k not in dict2.keys():\n",
" dict2[k] = v\n",
" else:\n",
" for k1,v1 in v.items():\n",
" dict2[k][k1] = v1\n",
"filename = f'data/result_长炼医院({rq}).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))\n",
"filename = 'data/result_长炼医院.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2, fl, ensure_ascii=False) \n",
"print(len(dict2))"
]
},
{
"cell_type": "markdown",
"id": "f220ffba-d172-4b6f-8238-c3a2d6c87ed4",
"metadata": {},
"source": [
"## 每日成绩导出"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "2ffa583b-be51-40a8-bb55-de6a89d1a54a",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-26T02:09:54.362083Z",
"iopub.status.busy": "2023-04-26T02:09:54.361227Z",
"iopub.status.idle": "2023-04-26T02:09:54.389991Z",
"shell.execute_reply": "2023-04-26T02:09:54.388984Z",
"shell.execute_reply.started": "2023-04-26T02:09:54.362051Z"
},
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"rq = '20230425'\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"filename = f'data/result_长炼医院({rq}).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/长炼医院人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
" \n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" list2 = []\n",
" list2.append(str(k).rjust(5,'0'))\n",
" list2.append(v['name']) \n",
" list2.append(dict2[k]['sex'])\n",
" list2.append(dict2[k]['unit']) \n",
" for item in items:\n",
" if item in v.keys():\n",
" list2.append(v[item]['成绩']) \n",
" elif item =='name':\n",
" list2.append(v[item])\n",
" else:\n",
" list2.append('') \n",
" list1.append(list2)\n",
"filename = f'data/长炼医院体测情况表({rq}).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ec011c39-f6b1-40d5-b95e-bc59b7a51058",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}