20251117
This commit is contained in:
1 parent
48f119d087
commit
31ddcb887f
9 files changed
+1089
-276
No files matched your search
+301
-43
@@ -2165,9 +2165,7 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 2024年体质检测"
|
||||
]
|
||||
@@ -3042,10 +3040,26 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 13,
|
||||
"id": "58f6dbab-9ea2-4295-ae78-36951b67c2d3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T07:32:41.466054Z",
|
||||
"iopub.status.busy": "2025-11-17T07:32:41.465351Z",
|
||||
"iopub.status.idle": "2025-11-17T07:32:41.591984Z",
|
||||
"shell.execute_reply": "2025-11-17T07:32:41.591337Z",
|
||||
"shell.execute_reply.started": "2025-11-17T07:32:41.465990Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"880 ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
@@ -3186,15 +3200,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 57,
|
||||
"execution_count": 14,
|
||||
"id": "7b79c7bb-ce87-44b2-95b1-01e9cb66d5f0",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-13T05:44:27.934101Z",
|
||||
"iopub.status.busy": "2025-11-13T05:44:27.933541Z",
|
||||
"iopub.status.idle": "2025-11-13T05:44:27.991293Z",
|
||||
"shell.execute_reply": "2025-11-13T05:44:27.990805Z",
|
||||
"shell.execute_reply.started": "2025-11-13T05:44:27.934053Z"
|
||||
"iopub.execute_input": "2025-11-17T07:32:53.282654Z",
|
||||
"iopub.status.busy": "2025-11-17T07:32:53.281905Z",
|
||||
"iopub.status.idle": "2025-11-17T07:32:53.332471Z",
|
||||
"shell.execute_reply": "2025-11-17T07:32:53.331897Z",
|
||||
"shell.execute_reply.started": "2025-11-17T07:32:53.282586Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -3236,15 +3250,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 60,
|
||||
"execution_count": 15,
|
||||
"id": "458725a6-3b5b-48a1-af90-cd4d0bda3635",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-13T05:51:01.753768Z",
|
||||
"iopub.status.busy": "2025-11-13T05:51:01.752925Z",
|
||||
"iopub.status.idle": "2025-11-13T05:51:01.812931Z",
|
||||
"shell.execute_reply": "2025-11-13T05:51:01.812381Z",
|
||||
"shell.execute_reply.started": "2025-11-13T05:51:01.753692Z"
|
||||
"iopub.execute_input": "2025-11-17T07:33:02.993633Z",
|
||||
"iopub.status.busy": "2025-11-17T07:33:02.993053Z",
|
||||
"iopub.status.idle": "2025-11-17T07:33:03.110653Z",
|
||||
"shell.execute_reply": "2025-11-17T07:33:03.109552Z",
|
||||
"shell.execute_reply.started": "2025-11-17T07:33:02.993579Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -3278,6 +3292,72 @@
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "aff5b1b6-a6af-44dd-beb0-cb2b68999496",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 生成测试得分"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"id": "ef655e34-635b-4baa-97c3-925022f45949",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T10:47:57.459196Z",
|
||||
"iopub.status.busy": "2025-11-17T10:47:57.458528Z",
|
||||
"iopub.status.idle": "2025-11-17T10:47:57.506947Z",
|
||||
"shell.execute_reply": "2025-11-17T10:47:57.506509Z",
|
||||
"shell.execute_reply.started": "2025-11-17T10:47:57.459138Z"
|
||||
}
|
||||
},
|
||||
"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": "12b33ee8-2b4e-4b85-9301-4fbcadf4129c",
|
||||
@@ -3407,15 +3487,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 65,
|
||||
"execution_count": 16,
|
||||
"id": "0bbf2cb6-e7d9-4d0d-beba-77ac50082f05",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-13T06:17:23.628451Z",
|
||||
"iopub.status.busy": "2025-11-13T06:17:23.627881Z",
|
||||
"iopub.status.idle": "2025-11-13T06:17:23.729071Z",
|
||||
"shell.execute_reply": "2025-11-13T06:17:23.728586Z",
|
||||
"shell.execute_reply.started": "2025-11-13T06:17:23.628397Z"
|
||||
"iopub.execute_input": "2025-11-17T07:33:16.521656Z",
|
||||
"iopub.status.busy": "2025-11-17T07:33:16.520913Z",
|
||||
"iopub.status.idle": "2025-11-17T07:33:16.617830Z",
|
||||
"shell.execute_reply": "2025-11-17T07:33:16.617274Z",
|
||||
"shell.execute_reply.started": "2025-11-17T07:33:16.521587Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -3427,7 +3507,7 @@
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251113.csv'\n",
|
||||
"filename = 'data/sql_20251117.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -3452,7 +3532,72 @@
|
||||
" list2 = [code,dict3[code]['name'],dict3[code]['unit'],phone_num]\n",
|
||||
" list3.append(list2)\n",
|
||||
"title =['测试编号','姓名','部门','手机号码']\n",
|
||||
"filename = 'data/北海炼化问卷人员(截至20251113).xlsx'\n",
|
||||
"filename = 'data/北海炼化问卷人员(截至20251116).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
"for row in list3:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "60d7de83-75aa-44bf-99da-492627032ca1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 问卷不符合信息人员"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "d3c0061f-fc24-483e-8e93-08872c77547f",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T01:29:17.936230Z",
|
||||
"iopub.status.busy": "2025-11-17T01:29:17.935493Z",
|
||||
"iopub.status.idle": "2025-11-17T01:29:17.974203Z",
|
||||
"shell.execute_reply": "2025-11-17T01:29:17.973659Z",
|
||||
"shell.execute_reply.started": "2025-11-17T01:29:17.936162Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251117.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",
|
||||
" list1.append(line)\n",
|
||||
"filename = 'data/北海炼化人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone = {}\n",
|
||||
"for k,v in dict3.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone[str(v['phone'])] = k\n",
|
||||
"dict2 = {}\n",
|
||||
"list3 = []\n",
|
||||
"for item in list1: \n",
|
||||
" phone_num = str(item[0])[2:] \n",
|
||||
" if phone_num not in phone:\n",
|
||||
" list2 = []\n",
|
||||
" content = json.loads(json.loads(item[1])) \n",
|
||||
" code = phone_num\n",
|
||||
" list2 = [code,content['name'],content['birth'],content['gender']]\n",
|
||||
" list3.append(list2)\n",
|
||||
"title =['测试编号','姓名','部门','手机号码']\n",
|
||||
"filename = 'data/北海炼化问卷信息不符合人员(截至20251116).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
@@ -3464,15 +3609,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"execution_count": 8,
|
||||
"id": "277fce35-2f95-4d52-8cab-4e27c9acd7b8",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-10T09:40:12.759033Z",
|
||||
"iopub.status.busy": "2025-11-10T09:40:12.758367Z",
|
||||
"iopub.status.idle": "2025-11-10T09:40:12.843476Z",
|
||||
"shell.execute_reply": "2025-11-10T09:40:12.842924Z",
|
||||
"shell.execute_reply.started": "2025-11-10T09:40:12.758969Z"
|
||||
"iopub.execute_input": "2025-11-17T01:22:21.248136Z",
|
||||
"iopub.status.busy": "2025-11-17T01:22:21.247270Z",
|
||||
"iopub.status.idle": "2025-11-17T01:22:21.339031Z",
|
||||
"shell.execute_reply": "2025-11-17T01:22:21.338544Z",
|
||||
"shell.execute_reply.started": "2025-11-17T01:22:21.248063Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -3487,7 +3632,7 @@
|
||||
"dict1 = {}\n",
|
||||
"list1 = []\n",
|
||||
"list2 = set()\n",
|
||||
"filename = 'data/sql_20251110.csv'\n",
|
||||
"filename = 'data/sql_20251117.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -3530,7 +3675,7 @@
|
||||
" list4 = [phone,v['name'],v['unit']]\n",
|
||||
" list3.append(list4)\n",
|
||||
"title =['手机号码','姓名','部门']\n",
|
||||
"filename = 'data/北海炼化未参加问卷人员(截至20251110).xlsx'\n",
|
||||
"filename = 'data/北海炼化未参加问卷人员(截至20251116).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
@@ -3552,15 +3697,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 62,
|
||||
"execution_count": 6,
|
||||
"id": "f67f63d1-be8a-47ef-b95f-bdfca9725838",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-13T06:00:49.916395Z",
|
||||
"iopub.status.busy": "2025-11-13T06:00:49.915561Z",
|
||||
"iopub.status.idle": "2025-11-13T06:00:50.043798Z",
|
||||
"shell.execute_reply": "2025-11-13T06:00:50.043247Z",
|
||||
"shell.execute_reply.started": "2025-11-13T06:00:49.916323Z"
|
||||
"iopub.execute_input": "2025-11-17T01:19:30.426467Z",
|
||||
"iopub.status.busy": "2025-11-17T01:19:30.425891Z",
|
||||
"iopub.status.idle": "2025-11-17T01:19:30.551084Z",
|
||||
"shell.execute_reply": "2025-11-17T01:19:30.550545Z",
|
||||
"shell.execute_reply.started": "2025-11-17T01:19:30.426412Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -3574,7 +3719,7 @@
|
||||
"\n",
|
||||
"dict1 = {}\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251110.csv'\n",
|
||||
"filename = 'data/sql_20251117.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -3615,7 +3760,7 @@
|
||||
" list2 = [k,v['name'],v['sex'],v['birth']]\n",
|
||||
" list1.append(list2)\n",
|
||||
"title =['手机号码','姓名','性别','出生年月']\n",
|
||||
"filename = 'data/北海炼化问卷人员(截至20251110).xlsx'\n",
|
||||
"filename = 'data/北海炼化问卷人员(截至20251116).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
@@ -3702,10 +3847,123 @@
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fc7701c1-0ce3-4fb9-a8eb-c9f8f2d44337",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导入问卷信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"id": "4628f644-a571-4f2b-8d7b-e6b60b2ddcfd",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T12:25:33.111224Z",
|
||||
"iopub.status.busy": "2025-11-17T12:25:33.110488Z",
|
||||
"iopub.status.idle": "2025-11-17T12:25:33.267732Z",
|
||||
"shell.execute_reply": "2025-11-17T12:25:33.267196Z",
|
||||
"shell.execute_reply.started": "2025-11-17T12:25:33.111154Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"781\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251117.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",
|
||||
" list1.append(line)\n",
|
||||
"filename = 'data/北海炼化人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"filename = 'data/result_北海2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"phone = {}\n",
|
||||
"for k,v in dict3.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone[str(v['phone'])] = k\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"nn = 0\n",
|
||||
"for item in list1:\n",
|
||||
" dict2 = {}\n",
|
||||
" \n",
|
||||
" phone_num = str(item[0])[2:]\n",
|
||||
" if phone_num in phone:\n",
|
||||
" content = json.loads(json.loads(item[1]))\n",
|
||||
" tcm = []\n",
|
||||
" spine = []\n",
|
||||
" psy = []\n",
|
||||
" for i in range(0,45):\n",
|
||||
" psy.append(0)\n",
|
||||
" psy[44] = []\n",
|
||||
" for i in range(0,60):\n",
|
||||
" tcm.append(0)\n",
|
||||
" for i in range(0,26):\n",
|
||||
" spine.append(0)\n",
|
||||
" for k, v in content.items(): \n",
|
||||
" if 'psy' in k:\n",
|
||||
" i = int(k[3:])\n",
|
||||
" psy[i-1] = int(v)\n",
|
||||
" if 'tcm' in k:\n",
|
||||
" i = int(k[3:])\n",
|
||||
" tcm[i-1] = int(v)\n",
|
||||
" if 'spine' in k:\n",
|
||||
" i = int(k[5:])\n",
|
||||
" if i<23:\n",
|
||||
" spine[i-1] = int(v)\n",
|
||||
" else:\n",
|
||||
" spine[i] = int(v)\n",
|
||||
" for i in range(26,40):\n",
|
||||
" new_valve = 1+psy[i]\n",
|
||||
" psy[i] = new_valve \n",
|
||||
" code = phone[phone_num]\n",
|
||||
" if code in dict3.keys() and code in dict1.keys(): \n",
|
||||
" dict1[code]['tcm'] = tcm \n",
|
||||
" dict1[code]['spine'] = spine\n",
|
||||
" dict1[code]['psy'] = psy\n",
|
||||
" elif code not in dict1.keys(): \n",
|
||||
" dict1.setdefault(code,{})\n",
|
||||
" dict1[code] = dict3[code]\n",
|
||||
" birth = date.fromisoformat(dict3[code]['birth'])\n",
|
||||
" rq = date.fromisoformat('2025-11-17')\n",
|
||||
" days = (rq-birth).days \n",
|
||||
" dict1[code]['age'] = int(days/365)\n",
|
||||
" dict1[code]['month'] = int(days/365*12)\n",
|
||||
" dict1[code]['rq'] = '2025-11-17'\n",
|
||||
" dict1[code]['tcm'] = tcm \n",
|
||||
" dict1[code]['spine'] = spine\n",
|
||||
" dict1[code]['psy'] = psy\n",
|
||||
"filename = 'data/result_北海2025-1.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||
"print(len(dict1))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "4b58eeae-089d-4007-ab5a-1e1e9e088dd7",
|
||||
"id": "013474d1-e2e0-4562-bd72-80ec9425f0c9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user