20250609
This commit is contained in:
1 parent
9ccc2271eb
commit
d4c40dcab2
2 files changed
+246
-66
No files matched your search
+199
-10
@@ -838,7 +838,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d3649684-3eab-49ad-8b3d-ebb452289e51",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"source": [
|
||||
"# 2024年体质检测"
|
||||
]
|
||||
@@ -1295,15 +1297,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 10,
|
||||
"id": "3e6da1e5-4b4e-448a-9663-815372da636b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-01T02:24:52.000744Z",
|
||||
"iopub.status.busy": "2025-06-01T02:24:52.000187Z",
|
||||
"iopub.status.idle": "2025-06-01T02:24:52.059953Z",
|
||||
"shell.execute_reply": "2025-06-01T02:24:52.059389Z",
|
||||
"shell.execute_reply.started": "2025-06-01T02:24:52.000689Z"
|
||||
"iopub.execute_input": "2025-06-08T01:20:13.742945Z",
|
||||
"iopub.status.busy": "2025-06-08T01:20:13.742373Z",
|
||||
"iopub.status.idle": "2025-06-08T01:20:13.794862Z",
|
||||
"shell.execute_reply": "2025-06-08T01:20:13.794371Z",
|
||||
"shell.execute_reply.started": "2025-06-08T01:20:13.742894Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -1333,8 +1335,9 @@
|
||||
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
||||
" dict1['unit'] = sheet.cell(n, 6).value\n",
|
||||
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0] \n",
|
||||
" dict1['phone'] = sheet.cell(n,7).value\n",
|
||||
" dict1['id'] = str(sheet.cell(n,2).value)\n",
|
||||
" if sheet.cell(n, 7).value is not None:\n",
|
||||
" dict1['phone'] = sheet.cell(n,7).value\n",
|
||||
" #dict1['id'] = str(sheet.cell(n,2).value)\n",
|
||||
" person[code] = dict1\n",
|
||||
"filename = 'data/东营石油工程设计院2025.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
@@ -1394,10 +1397,196 @@
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e185883c-5c98-4090-883d-7ea643279b06",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 获取人员测试成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "d07d132b-dd74-458d-af0c-6a6ae005ad3a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-09T05:54:53.309142Z",
|
||||
"iopub.status.busy": "2025-06-09T05:54:53.308597Z",
|
||||
"iopub.status.idle": "2025-06-09T05:54:53.339265Z",
|
||||
"shell.execute_reply": "2025-06-09T05:54:53.338794Z",
|
||||
"shell.execute_reply.started": "2025-06-09T05:54:53.309094Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"246\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import datetime\n",
|
||||
"import csv\n",
|
||||
"from datetime import date\n",
|
||||
"import my_module as My\n",
|
||||
"\n",
|
||||
"filename = 'data/东营石油工程设计院2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"filename = 'data/marks_20250609.csv'\n",
|
||||
"re_ta = My.get_result(filename,dict1)\n",
|
||||
"\n",
|
||||
"filename = 'data/result_东营石油工程设计院2025.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a558472a-8428-476a-932a-3e723c9aa76b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 生成测试得分"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "971d592d-9ff5-4758-af68-2f60a986c2a2",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-09T05:55:52.911728Z",
|
||||
"iopub.status.busy": "2025-06-09T05:55:52.910950Z",
|
||||
"iopub.status.idle": "2025-06-09T05:55:52.934192Z",
|
||||
"shell.execute_reply": "2025-06-09T05:55:52.933606Z",
|
||||
"shell.execute_reply.started": "2025-06-09T05:55:52.911653Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
"import my_module as My\n",
|
||||
"\n",
|
||||
"#list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','height','weight']\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||
"filename = 'data/result_东营石油工程设计院2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" #print(k)\n",
|
||||
" if v['sex'] == '男':\n",
|
||||
" sex = 'M'\n",
|
||||
" else:\n",
|
||||
" sex = 'F' \n",
|
||||
" if 'bmi' in v.keys():\n",
|
||||
" #bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
|
||||
" bmi_data = v['bmi']['成绩']\n",
|
||||
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':'HeightWeight','result':bmi_data}\n",
|
||||
" dict2[k]['bmi'] = {}\n",
|
||||
" dict2[k]['bmi']['成绩'] = bmi_data\n",
|
||||
" dict2[k]['bmi']['score'] = My.cal_bmi(data1)\n",
|
||||
" for item_en in list_item:\n",
|
||||
" if item_en in v.keys(): \n",
|
||||
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':item_en,'result':float(v[item_en]['成绩'].split()[0])}\n",
|
||||
" #print(k,v['name'])\n",
|
||||
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
|
||||
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||||
"\n",
|
||||
"filename = f'data/result_东营石油工程设计院2025.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||
"print('ok!') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "91afcf8e-9a70-438a-b956-8a195ddb0de8",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导出测试人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"id": "fe5dc201-ee74-40a6-a7e3-4d9f8c0e05ed",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-09T05:57:30.861539Z",
|
||||
"iopub.status.busy": "2025-06-09T05:57:30.860835Z",
|
||||
"iopub.status.idle": "2025-06-09T05:57:30.983605Z",
|
||||
"shell.execute_reply": "2025-06-09T05:57:30.983113Z",
|
||||
"shell.execute_reply.started": "2025-06-09T05:57:30.861474Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"\n",
|
||||
"filename = 'data/result_东营石油工程设计院2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/东营石油工程设计院2025.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",
|
||||
" if 'bmi' in v.keys():\n",
|
||||
" height = v['bmi']['成绩'].split(',')[0]\n",
|
||||
" weight = v['bmi']['成绩'].split(',')[1]\n",
|
||||
" list2.append(height)\n",
|
||||
" list2.append(weight)\n",
|
||||
" else:\n",
|
||||
" list2.append('')\n",
|
||||
" list2.append('')\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",
|
||||
" \n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/东营石油工程设计院情况表2025.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": "d7bcbeb2-2e6e-40a4-b1ef-35b95462dc44",
|
||||
"id": "d6e1066a-7779-407f-8b8d-109ada157acc",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user