This commit is contained in:
512song committed 2023-09-16 20:35:28 +08:00
1 parent 01614b040a
commit e1da612c61
2 files changed
+186 -61

No files matched your search

+158 -5
View File
@@ -3,7 +3,10 @@
{
"cell_type": "markdown",
"id": "55644860-57e6-466b-b6e9-e6fdd807498d",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"# 员工体测"
]
@@ -910,12 +913,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "3f1b2284-c39e-4dc2-bc0c-983fb8e3417f",
"metadata": {
"execution": {
"iopub.execute_input": "2023-09-16T11:56:29.189193Z",
"iopub.status.busy": "2023-09-16T11:56:29.188795Z",
"iopub.status.idle": "2023-09-16T11:56:29.210384Z",
"shell.execute_reply": "2023-09-16T11:56:29.209858Z",
"shell.execute_reply.started": "2023-09-16T11:56:29.189160Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"508\n",
"508\n"
]
}
],
"source": [
"import json\n",
"import time\n",
@@ -954,7 +973,7 @@
" 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",
" re_ta[user][item_name]['成绩'] = f'{score}'\n",
"print(len(re_ta))\n",
"\n",
"filename = 'data/result_长岭学生.json'\n",
@@ -1018,10 +1037,144 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "707eec10-0650-4063-b25d-d833edf0f50b",
"metadata": {},
"source": [
"## 汇总手工数据"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "6f4341d7-b836-4186-a4c6-370e9e207e0a",
"metadata": {
"execution": {
"iopub.execute_input": "2023-09-16T11:56:38.115567Z",
"iopub.status.busy": "2023-09-16T11:56:38.115110Z",
"iopub.status.idle": "2023-09-16T11:56:38.239480Z",
"shell.execute_reply": "2023-09-16T11:56:38.239046Z",
"shell.execute_reply.started": "2023-09-16T11:56:38.115531Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8076\n",
"8113\n",
"8137\n",
"8228\n",
"8239\n",
"8283\n",
"8299\n",
"8416\n",
"8488\n",
"8504\n",
"ok\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"filename = f'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",
"wb = openpyxl.load_workbook('data/潭溪小学学生体测数据.xlsx')\n",
"sheet = wb.active\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,4).value is not None:\n",
" code = int(sheet.cell(n, 4).value)\n",
" if str(code) not in dict1.keys():\n",
" dict1[str(code)] = dict2[str(code)]\n",
" print(code)\n",
" else:\n",
" dict1[str(code)]['birth'] = dict2[str(code)]['birth']\n",
" if sheet.cell(n,8).value is not None:\n",
" dict1[str(code)].setdefault('50米跑',{})\n",
" dict1[str(code)]['50米跑']['成绩'] = sheet.cell(n,8).value\n",
" if sheet.cell(n,9).value is not None:\n",
" dict1[str(code)].setdefault('一分钟跳绳',{})\n",
" dict1[str(code)]['一分钟跳绳']['成绩'] = sheet.cell(n,9).value\n",
" if sheet.cell(n,10).value is not None:\n",
" dict1[str(code)].setdefault('一分钟仰卧起坐',{})\n",
" dict1[str(code)]['一分钟仰卧起坐']['成绩'] = sheet.cell(n,10).value\n",
" if sheet.cell(n,11).value is not None:\n",
" dict1[str(code)].setdefault('50米x8往返跑',{})\n",
" dict1[str(code)]['50米x8往返跑']['成绩'] = sheet.cell(n,11).value\n",
"filename = f'data/result_长岭学生all.json'\n",
"\n",
"with open(filename, 'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print('ok') \n"
]
},
{
"cell_type": "markdown",
"id": "de34017a-cbdb-4f76-adf3-453c698bdc3b",
"metadata": {},
"source": [
"## 导出汇总数据"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "04e27e02-7a69-42a8-a21a-61151a8a1427",
"metadata": {
"execution": {
"iopub.execute_input": "2023-09-16T11:58:41.367300Z",
"iopub.status.busy": "2023-09-16T11:58:41.366840Z",
"iopub.status.idle": "2023-09-16T11:58:41.486698Z",
"shell.execute_reply": "2023-09-16T11:58:41.486218Z",
"shell.execute_reply.started": "2023-09-16T11:58:41.367264Z"
},
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"filename = f'data/result_长岭学生all.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"items = ['身高','体重','肺活量','坐位体前屈','50米跑','一分钟跳绳','一分钟仰卧起坐','50米x8往返跑']\n",
"for k, v in dict1.items(): \n",
" list2 = []\n",
" list2.append(str(k))\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",
" else:\n",
" list2.append('') \n",
" list1.append(list2)\n",
"filename = f'data/长岭学生体测情况表.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
"wb.save(filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1b35c133-928f-40d9-8523-8a16677a55d8",
"id": "bc2b121a-948f-481a-b777-5879883d3c10",
"metadata": {},
"outputs": [],
"source": []