20230506
This commit is contained in:
1 parent
89ae72f87e
commit
3c8e9c5157
8 files changed
+728
-191
No files matched your search
+136
-70
@@ -72,15 +72,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 10,
|
||||
"id": "d0cb294b-d403-4c4c-9de6-61ec98cf9797",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-15T14:31:21.405573Z",
|
||||
"iopub.status.busy": "2023-04-15T14:31:21.404701Z",
|
||||
"iopub.status.idle": "2023-04-15T14:31:21.431005Z",
|
||||
"shell.execute_reply": "2023-04-15T14:31:21.429944Z",
|
||||
"shell.execute_reply.started": "2023-04-15T14:31:21.405535Z"
|
||||
"iopub.execute_input": "2023-05-05T06:41:07.266525Z",
|
||||
"iopub.status.busy": "2023-05-05T06:41:07.266100Z",
|
||||
"iopub.status.idle": "2023-05-05T06:41:07.287905Z",
|
||||
"shell.execute_reply": "2023-05-05T06:41:07.286990Z",
|
||||
"shell.execute_reply.started": "2023-05-05T06:41:07.266497Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
@@ -121,36 +121,44 @@
|
||||
" list1.append(line)\n",
|
||||
"#print(list1)\n",
|
||||
"for result in list1:\n",
|
||||
" user = str(result[4])\n",
|
||||
" user = str(result[2])\n",
|
||||
" if user in dict1.keys():\n",
|
||||
" \n",
|
||||
" m_item = str(result[0]) \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[1])/item[m_item]['divisor'] \n",
|
||||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||
" re_ta[user][item_name]['得分'] =result[2]\n",
|
||||
"filename = 'data/result_上地派出所.json'\n",
|
||||
" re_ta[user][item_name]['得分'] =result[5]\n",
|
||||
"filename = 'data/result_上地派出所1.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ac363a21-83aa-42e5-a82b-fd051e4b86a7",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 计算测试成绩平均分"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "78e461ac-1074-4bce-a2a5-4cd60f3b7ae2",
|
||||
"execution_count": 19,
|
||||
"id": "4f5a8416-3536-4c52-bfdc-758420e519d3",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-15T14:36:06.348606Z",
|
||||
"iopub.status.busy": "2023-04-15T14:36:06.348205Z",
|
||||
"iopub.status.idle": "2023-04-15T14:36:06.363398Z",
|
||||
"shell.execute_reply": "2023-04-15T14:36:06.362284Z",
|
||||
"shell.execute_reply.started": "2023-04-15T14:36:06.348579Z"
|
||||
"iopub.execute_input": "2023-05-05T07:17:09.764428Z",
|
||||
"iopub.status.busy": "2023-05-05T07:17:09.763611Z",
|
||||
"iopub.status.idle": "2023-05-05T07:17:09.782569Z",
|
||||
"shell.execute_reply": "2023-05-05T07:17:09.781678Z",
|
||||
"shell.execute_reply.started": "2023-05-05T07:17:09.764387Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
@@ -159,52 +167,37 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"44\n"
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"filename = '../item.json'\n",
|
||||
"item = {}\n",
|
||||
"unit = {}\n",
|
||||
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','单位/部门','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
||||
"filename = 'data/result_上地派出所1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" item[k] = v\n",
|
||||
"filename = 'data/上地派出所人员名单.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"re_ta = {}\n",
|
||||
"dict2 = {}\n",
|
||||
"list1 = []\n",
|
||||
"#print(\"\\n运动项目信息:\")\n",
|
||||
"filename = 'data/142.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[4])\n",
|
||||
" if user in dict1.keys():\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" i = 0\n",
|
||||
" score = 0\n",
|
||||
" for k1, v1 in v.items():\n",
|
||||
" \n",
|
||||
" m_item = str(result[0]) \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[1])/item[m_item]['divisor'] \n",
|
||||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||
" re_ta[user][item_name]['得分'] =result[2]\n",
|
||||
"print(len(re_ta))"
|
||||
" if k1 in items:\n",
|
||||
" score = score + int(v1['得分'])\n",
|
||||
" i = i + 1\n",
|
||||
" pjf = score / i\n",
|
||||
" dict1[k]['总分'] = score\n",
|
||||
" dict1[k]['平均分'] = round(score / i,2)\n",
|
||||
"filename = 'data/result_上地派出所.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl) \n",
|
||||
"print('ok')\n",
|
||||
" \n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -217,15 +210,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 22,
|
||||
"id": "eafc36e7-6a8d-4744-b5ff-9cc0c624c732",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-15T14:33:22.621334Z",
|
||||
"iopub.status.busy": "2023-04-15T14:33:22.620509Z",
|
||||
"iopub.status.idle": "2023-04-15T14:33:22.666051Z",
|
||||
"shell.execute_reply": "2023-04-15T14:33:22.665054Z",
|
||||
"shell.execute_reply.started": "2023-04-15T14:33:22.621295Z"
|
||||
"iopub.execute_input": "2023-05-05T07:19:08.537806Z",
|
||||
"iopub.status.busy": "2023-05-05T07:19:08.536964Z",
|
||||
"iopub.status.idle": "2023-05-05T07:19:08.596852Z",
|
||||
"shell.execute_reply": "2023-05-05T07:19:08.595844Z",
|
||||
"shell.execute_reply.started": "2023-05-05T07:19:08.537767Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
@@ -235,7 +228,7 @@
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','单位/部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','单位/部门','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
||||
"filename = 'data/result_上地派出所.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
@@ -248,17 +241,20 @@
|
||||
"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]['name']) \n",
|
||||
" list2.append(dict2[k]['sex'])\n",
|
||||
" list2.append(dict2[k]['unit']) \n",
|
||||
" \n",
|
||||
" list2.append(dict2[k]['unit'])\n",
|
||||
" for item in items:\n",
|
||||
" if item in v.keys():\n",
|
||||
" list2.append(v[item]['成绩']) \n",
|
||||
" if item in dict1[k].keys():\n",
|
||||
" list2.append(dict1[k][item]['成绩'])\n",
|
||||
" list2.append(dict1[k][item]['得分']) \n",
|
||||
" elif item =='name':\n",
|
||||
" list2.append(v[item])\n",
|
||||
" list2.append(dict1[k][item])\n",
|
||||
" else:\n",
|
||||
" list2.append('') \n",
|
||||
" list2.append('')\n",
|
||||
" list2.append(dict1[k]['总分'])\n",
|
||||
" list2.append(dict1[k]['平均分'])\n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/上地派出所体测情况表.xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
@@ -270,10 +266,80 @@
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c6ef75ff-0aa5-422d-a21c-98e2ebe89672",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计项目平均分"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"id": "228b4f0c-deac-41e7-a995-e6d3ea4a0cdf",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-05-05T08:40:23.243572Z",
|
||||
"iopub.status.busy": "2023-05-05T08:40:23.242724Z",
|
||||
"iopub.status.idle": "2023-05-05T08:40:23.257387Z",
|
||||
"shell.execute_reply": "2023-05-05T08:40:23.256275Z",
|
||||
"shell.execute_reply.started": "2023-05-05T08:40:23.243532Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"体重 3.18\n",
|
||||
"肺活量 3.75\n",
|
||||
"握力 2.23\n",
|
||||
"坐位体前屈 2.79\n",
|
||||
"纵跳 2.72\n",
|
||||
"俯卧撑 3.24\n",
|
||||
"一分钟仰卧起坐 3.83\n",
|
||||
"单脚站立 1.77\n",
|
||||
"选择反应时 3.73\n",
|
||||
"台阶指数 2.52\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','单位/部门','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
||||
"filename = 'data/result_上地派出所.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",
|
||||
"\n",
|
||||
"for item in items:\n",
|
||||
" i = 0\n",
|
||||
" score = 0\n",
|
||||
" for k, v in dict1.items():\n",
|
||||
" if item in v.keys():\n",
|
||||
" score = int(v[item]['得分']) + score \n",
|
||||
" i = i + 1\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" print(item,round(score/i,2)) \n",
|
||||
" \n",
|
||||
" \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "6f7c8be9-8910-4570-bc09-45f464c77ce9",
|
||||
"id": "fc3c36c2-4697-4709-b755-ec6ade9451bd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user