From 82372feb99318613ca3060ae21fa595e5249274c Mon Sep 17 00:00:00 2001 From: 512song Date: Wed, 11 Dec 2024 18:57:54 +0800 Subject: [PATCH] 20241211 --- 体测单位/体质检测数据处理.ipynb | 132 ++++++++-- 体测单位/北海炼化.ipynb | 1 - 体测单位/长炼医院.ipynb | 430 ++++++++++++++++++++++++++++++-- 3 files changed, 512 insertions(+), 51 deletions(-) diff --git a/体测单位/体质检测数据处理.ipynb b/体测单位/体质检测数据处理.ipynb index aefb371..e9d5afb 100644 --- a/体测单位/体质检测数据处理.ipynb +++ b/体测单位/体质检测数据处理.ipynb @@ -497,17 +497,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "141b30dc-5975-4dcb-9bc3-9b20d26a0917", "metadata": { + "execution": { + "iopub.execute_input": "2024-12-11T07:12:20.657211Z", + "iopub.status.busy": "2024-12-11T07:12:20.656910Z", + "iopub.status.idle": "2024-12-11T07:12:20.675619Z", + "shell.execute_reply": "2024-12-11T07:12:20.675056Z", + "shell.execute_reply.started": "2024-12-11T07:12:20.657186Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok!\n" + ] + } + ], "source": [ "import json\n", "import time\n", "\n", - "filename = '../item.json'\n", + "filename = '../item1.json'\n", "item = {}\n", "unit = {}\n", "with open(filename,'r') as fl:\n", @@ -600,7 +615,7 @@ "\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_天津石化2024.json'\n", + "filename = 'data/result_长炼医院人员2024(湖南青年).json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl) \n", "for k, v in dict2.items():\n", @@ -621,7 +636,7 @@ " dict2[k][item_en]['score'] = cal_score(data1)\n", " #print(k,v[item_en]['成绩'],cal_score(data1))\n", "\n", - "filename = f'data/result_天津石化2024.json'\n", + "filename = f'data/result_长炼医院人员2024(湖南青年).json'\n", "with open(filename,'w') as fl:\n", " json.dump(dict2,fl , ensure_ascii=False) \n", "print('ok!') " @@ -637,15 +652,15 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 8, "id": "b123ee6b-85d2-4660-b226-321832a6b796", "metadata": { "execution": { - "iopub.execute_input": "2024-12-06T14:42:19.023726Z", - "iopub.status.busy": "2024-12-06T14:42:19.023180Z", - "iopub.status.idle": "2024-12-06T14:49:16.425361Z", - "shell.execute_reply": "2024-12-06T14:49:16.424225Z", - "shell.execute_reply.started": "2024-12-06T14:42:19.023678Z" + "iopub.execute_input": "2024-12-11T07:12:25.035537Z", + "iopub.status.busy": "2024-12-11T07:12:25.034817Z", + "iopub.status.idle": "2024-12-11T07:13:06.145312Z", + "shell.execute_reply": "2024-12-11T07:13:06.144192Z", + "shell.execute_reply.started": "2024-12-11T07:12:25.035471Z" }, "tags": [] }, @@ -654,7 +669,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "757\n" + "78\n" ] } ], @@ -667,11 +682,11 @@ "headers = {\n", " \"Content-Type\": \"application/json; charset=UTF-8\"\n", " }\n", - "filename = 'data/result_北海炼化2024.json'\n", + "filename = 'data/result_长炼医院人员2024(湖南青年).json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "list1 = []\n", - "file_path ='./北海炼化2024/'\n", + "file_path ='./长炼医院2024(湖南青年)/'\n", "list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n", "i=0\n", "list2 = []\n", @@ -681,7 +696,7 @@ " \n", " id = str(k).rjust(4,\"0\")\n", " mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n", - " mydata['title'] = '中国石化北海炼化\\n有限责任公司'\n", + " mydata['title'] = '中石化长岭分公司'\n", " mydata['subtitle'] = v['unit']\n", " mydata['id'] = id\n", " mydata['name'] = v['name']\n", @@ -708,8 +723,8 @@ " else:\n", " mark = v[item]['成绩'].split()[0]\n", " mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n", - " if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n", - " #if len(mydata['fits']) >2 : \n", + " #if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n", + " if len(mydata['fits']) >2 : \n", " list1.append(mydata)\n", " list2.append([k,v['name']])\n", " i+=1\n", @@ -2367,7 +2382,7 @@ " for i in range(0,6):\n", " score = int(dict3[i+1]/list3[i][0]/list3[i][1]*100)\n", " list5.append(score)\n", - " list4.append(list5)\n", + " list4.append(list5)\n", "filename = 'data/北海炼化心理情况明细表2024.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", @@ -2389,15 +2404,15 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 63, "id": "122f19fb-3531-4074-94e4-e2afdb8af51a", "metadata": { "execution": { - "iopub.execute_input": "2024-12-06T14:23:42.730508Z", - "iopub.status.busy": "2024-12-06T14:23:42.729973Z", - "iopub.status.idle": "2024-12-06T14:23:42.794427Z", - "shell.execute_reply": "2024-12-06T14:23:42.793835Z", - "shell.execute_reply.started": "2024-12-06T14:23:42.730459Z" + "iopub.execute_input": "2024-12-08T04:21:58.990344Z", + "iopub.status.busy": "2024-12-08T04:21:58.989588Z", + "iopub.status.idle": "2024-12-08T04:21:59.054676Z", + "shell.execute_reply": "2024-12-08T04:21:59.054144Z", + "shell.execute_reply.started": "2024-12-08T04:21:58.990273Z" } }, "outputs": [ @@ -2427,7 +2442,7 @@ " score+= spine[ii]\n", " #print(k,list4[i],int(score/list5[i][2]*100)-100)\n", " list7.append(int(score/list5[i][2]*100)-100)\n", - " list6.append(list7)\n", + " list6.append(list7)\n", "filename = 'data/北海炼化脊柱情况明细表2024.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", @@ -2439,10 +2454,75 @@ "print('ok') " ] }, + { + "cell_type": "markdown", + "id": "b9d5bad6-4d72-43d7-b86b-55c9b9d33af2", + "metadata": {}, + "source": [ + "## 导出脊柱明细表" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "1a5a10cb-f6bc-4e3a-83cc-78b9c0cbe994", + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-08T04:24:23.871310Z", + "iopub.status.busy": "2024-12-08T04:24:23.870782Z", + "iopub.status.idle": "2024-12-08T04:24:24.037452Z", + "shell.execute_reply": "2024-12-08T04:24:24.036877Z", + "shell.execute_reply.started": "2024-12-08T04:24:23.871259Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "list4 = ['颈椎','胸椎','腰椎','骶尾椎']\n", + "list5 = [[0,10,10],[10,17,7],[17,24,6],[24,26,2]]\n", + "filename = 'data/result_北海炼化2024.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "list6 = []\n", + "for k, v in dict1.items():\n", + " if 'spine' in v.keys():\n", + " list7 = []\n", + " spine = v['spine']\n", + " list7.append(k)\n", + " list7.append(v['name'])\n", + " list7.append(v['sex'])\n", + " list7.append(v['age'])\n", + " for i in range(0,4):\n", + " score = 0\n", + " for ii in range(list5[i][0],list5[i][1]):\n", + " score+= spine[ii]\n", + " #print(k,list4[i],int(score/list5[i][2]*100)-100)\n", + " list7.append(int(score/list5[i][2]*100)-100)\n", + " for item in v['spine']:\n", + " list7.append(item)\n", + " list6.append(list7)\n", + "filename = 'data/北海炼化脊柱情况明细表2024.xlsx'\n", + "wb = openpyxl.Workbook()\n", + "sheet = wb.active\n", + "\n", + "for row in list6:\n", + " sheet.append(row)\n", + " \n", + "wb.save(filename)\n", + "print('ok') " + ] + }, { "cell_type": "code", "execution_count": null, - "id": "5912a87a-7b93-4b79-b708-dd23032e97ae", + "id": "1fcca066-04a7-41c1-8c5e-aea251b87250", "metadata": {}, "outputs": [], "source": [] diff --git a/体测单位/北海炼化.ipynb b/体测单位/北海炼化.ipynb index 7047ea0..e3e6ad9 100644 --- a/体测单位/北海炼化.ipynb +++ b/体测单位/北海炼化.ipynb @@ -4,7 +4,6 @@ "cell_type": "markdown", "id": "1c72f0cf-165b-4025-af9d-6771e4a0a5d1", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ diff --git a/体测单位/长炼医院.ipynb b/体测单位/长炼医院.ipynb index 1c32e76..2514afc 100644 --- a/体测单位/长炼医院.ipynb +++ b/体测单位/长炼医院.ipynb @@ -2309,15 +2309,15 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 24, "id": "610b20f3-9fd8-46fc-b8ee-d48c4c854289", "metadata": { "execution": { - "iopub.execute_input": "2024-07-08T07:09:49.763833Z", - "iopub.status.busy": "2024-07-08T07:09:49.763076Z", - "iopub.status.idle": "2024-07-08T07:09:49.792041Z", - "shell.execute_reply": "2024-07-08T07:09:49.791388Z", - "shell.execute_reply.started": "2024-07-08T07:09:49.763760Z" + "iopub.execute_input": "2024-12-09T09:22:38.802119Z", + "iopub.status.busy": "2024-12-09T09:22:38.801372Z", + "iopub.status.idle": "2024-12-09T09:22:38.835995Z", + "shell.execute_reply": "2024-12-09T09:22:38.835477Z", + "shell.execute_reply.started": "2024-12-09T09:22:38.802047Z" } }, "outputs": [ @@ -2350,6 +2350,8 @@ " dict1['birth'] = birth\n", " dict1['unit'] = sheet.cell(n, 2).value\n", " person[code] = dict1\n", + "del person[1]\n", + "del person[2]\n", "filename = 'data/湖南石化青年体质检测.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(person, fl, ensure_ascii=False)\n", @@ -2414,15 +2416,15 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 26, "id": "1e2d586e-6ff5-4fd1-a909-278d23e54561", "metadata": { "execution": { - "iopub.execute_input": "2024-12-06T06:27:42.919559Z", - "iopub.status.busy": "2024-12-06T06:27:42.918788Z", - "iopub.status.idle": "2024-12-06T06:27:42.945858Z", - "shell.execute_reply": "2024-12-06T06:27:42.945012Z", - "shell.execute_reply.started": "2024-12-06T06:27:42.919489Z" + "iopub.execute_input": "2024-12-09T09:26:07.189575Z", + "iopub.status.busy": "2024-12-09T09:26:07.187969Z", + "iopub.status.idle": "2024-12-09T09:26:07.219642Z", + "shell.execute_reply": "2024-12-09T09:26:07.219013Z", + "shell.execute_reply.started": "2024-12-09T09:26:07.189495Z" } }, "outputs": [ @@ -2430,8 +2432,78 @@ "name": "stdout", "output_type": "stream", "text": [ - "80\n", - "80\n" + "207\n", + "207\n" + ] + } + ], + "source": [ + "import json\n", + "import time\n", + "import csv\n", + "\n", + "filename = '../item1.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/长炼医院人员2024.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "filename = 'data/places_result_20241205-1.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_长炼医院人员2024.json'\n", + "\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl, ensure_ascii=False) \n", + "print(len(re_ta))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "0cad0490-5199-4ca3-bf6f-a206829d702e", + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-11T06:57:46.853287Z", + "iopub.status.busy": "2024-12-11T06:57:46.852519Z", + "iopub.status.idle": "2024-12-11T06:57:46.874391Z", + "shell.execute_reply": "2024-12-11T06:57:46.873811Z", + "shell.execute_reply.started": "2024-12-11T06:57:46.853199Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "78\n", + "78\n" ] } ], @@ -2475,7 +2547,112 @@ " 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_长炼医院人员2024.json'\n", + "filename = 'data/result_长炼医院人员2024(湖南青年).json'\n", + "\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl, ensure_ascii=False) \n", + "print(len(re_ta))" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "dd681c34-dba9-434b-9cd3-ed12fefcce0f", + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-11T07:10:57.109817Z", + "iopub.status.busy": "2024-12-11T07:10:57.109051Z", + "iopub.status.idle": "2024-12-11T07:10:57.134829Z", + "shell.execute_reply": "2024-12-11T07:10:57.134208Z", + "shell.execute_reply.started": "2024-12-11T07:10:57.109746Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "78\n", + "78\n" + ] + } + ], + "source": [ + "import json\n", + "import datetime\n", + "import csv\n", + "from datetime import date\n", + "\n", + "filename = '../item1.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", + "item['1']['en'] = 'lung'\n", + "item['2']['en'] = 'grip'\n", + "item['3']['en'] = 'flexion'\n", + "item['4']['en'] = 'jump'\n", + "item['5']['en'] = 'pushup'\n", + "item['6']['en'] = 'balance'\n", + "item['7']['en'] = 'reaction'\n", + "item['8']['en'] = 'step'\n", + "item['9']['en'] = 'situp'\n", + "item['10']['en'] = 'height'\n", + "item['11']['en'] = 'weight'\n", + "\n", + "\n", + "re_ta = {}\n", + "dict1 = {}\n", + "list1 = []\n", + "filename = 'data/湖南石化青年体质检测.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "\n", + "filename = 'data/places_result_20241205-1.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", + "#f_item = ['lung','grip','flexion','jump','balance','reaction','step','situp']\n", + "#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n", + "for result in list1:\n", + " user = str(result[2])\n", + " rq = date.fromisoformat(result[6].replace('/','-'))\n", + " if user in dict1.keys():\n", + " l_xm = []\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", + " if dict1[user]['sex'] == '男':\n", + " l_xm = ['weight','height','lung','grip','flexion','jump','pushup','balance','reaction','step']\n", + " else:\n", + " l_xm = ['weight','height','lung','grip','flexion','jump','balance','reaction','step','situp']\n", + " re_ta[user]['unit'] = dict1[user]['unit']\n", + " birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n", + " #birth = date.fromisoformat(dict1[user]['birth'])\n", + " #nian = int(birth[0].strip())\n", + " #yue = int(birth[1].strip())\n", + " #ri = int(birth[2].strip())\n", + " #print(k,nian,yue,ri)\n", + " item_name = item[m_item]['en'] \n", + " if item_name in l_xm: \n", + " days = (rq-birth).days \n", + " re_ta[user]['age'] = int(days/365)\n", + " re_ta[user]['month'] = int(days/365*12)\n", + " re_ta[user]['rq'] = result[6]\n", + "\n", + "\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_长炼医院人员2024(湖南青年).json'\n", "\n", "with open(filename,'w') as fl:\n", " json.dump(re_ta, fl, ensure_ascii=False) \n", @@ -2487,20 +2664,20 @@ "id": "8af6a13c-3be4-44ff-a937-ee5061454484", "metadata": {}, "source": [ - "## 导出测试人员信息" + "## 导出测试人员信息(湖南青年)" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 25, "id": "64c6e1e3-801c-4573-b78f-5a9e842597a9", "metadata": { "execution": { - "iopub.execute_input": "2024-12-06T06:28:00.400775Z", - "iopub.status.busy": "2024-12-06T06:28:00.400061Z", - "iopub.status.idle": "2024-12-06T06:28:00.445938Z", - "shell.execute_reply": "2024-12-06T06:28:00.445528Z", - "shell.execute_reply.started": "2024-12-06T06:28:00.400712Z" + "iopub.execute_input": "2024-12-09T09:23:41.690512Z", + "iopub.status.busy": "2024-12-09T09:23:41.689765Z", + "iopub.status.idle": "2024-12-09T09:23:41.726298Z", + "shell.execute_reply": "2024-12-09T09:23:41.725869Z", + "shell.execute_reply.started": "2024-12-09T09:23:41.690440Z" } }, "outputs": [], @@ -2515,7 +2692,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "\n", - "filename = 'data/长炼医院人员2024(汇总).json'\n", + "filename = 'data/湖南石化青年体质检测.json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl)\n", " \n", @@ -2545,10 +2722,215 @@ "wb.save(filename)" ] }, + { + "cell_type": "markdown", + "id": "02501bf0-0ba8-4143-b2ef-aeef767985d0", + "metadata": {}, + "source": [ + "## 导出测试人员信息(非湖南青年)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "933f3eb1-8463-4782-ae45-8a1628abbb2b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-09T09:29:03.983785Z", + "iopub.status.busy": "2024-12-09T09:29:03.983528Z", + "iopub.status.idle": "2024-12-09T09:29:04.043514Z", + "shell.execute_reply": "2024-12-09T09:29:04.042868Z", + "shell.execute_reply.started": "2024-12-09T09:29:03.983761Z" + } + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "\n", + "filename = 'data/result_长炼医院人员2024.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", + " dict3 = json.load(fl)\n", + "\n", + "filename = 'data/长炼医院人员2024.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", + "list1 = []\n", + "for k, v in dict1.items():\n", + " if k in dict2.keys() and k not in dict3.keys():\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 = 'data/长炼医院人员检测情况表(非湖南青年).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": "markdown", + "id": "83db1501-6625-4e72-9a5e-2184b8e309e9", + "metadata": {}, + "source": [ + "## 核对重名人员" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "dd7557bf-6f1e-4d01-aa93-5a4ad46a57a5", + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-11T06:12:49.795632Z", + "iopub.status.busy": "2024-12-11T06:12:49.794818Z", + "iopub.status.idle": "2024-12-11T06:12:49.967842Z", + "shell.execute_reply": "2024-12-11T06:12:49.967393Z", + "shell.execute_reply.started": "2024-12-11T06:12:49.795561Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3437581 李成伟\n", + "3526193 李可\n", + "3464205 胡雨丹\n", + "1010 邱亮\n", + "1012 吴磊\n", + "3464081 刘权\n", + "3125625 宋霰\n", + "1020 贾俊\n", + "1022 徐敬\n", + "1023 彭一夫\n", + "1024 刘至清\n", + "1053 刘志刚\n", + "1058 杨红\n", + "1069 李鑫\n", + "1144 黄英杰\n" + ] + } + ], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "\n", + "filename = 'data/长炼医院人员2024.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", + "\n", + "filename = 'data/湖南石化青年体质检测.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + " \n", + "set1 = set()\n", + "\n", + "for k, v in dict2.items():\n", + " set1.add(v['name'])\n", + "\n", + "for k, v in dict1.items():\n", + " if v['name'] in set1:\n", + " print(k,v['name'])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "ded0ac64-9ba2-4d64-9617-e0961b437d4e", + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-11T06:33:09.011061Z", + "iopub.status.busy": "2024-12-11T06:33:09.010467Z", + "iopub.status.idle": "2024-12-11T06:33:09.030379Z", + "shell.execute_reply": "2024-12-11T06:33:09.029760Z", + "shell.execute_reply.started": "2024-12-11T06:33:09.011010Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "29\n", + "29\n" + ] + } + ], + "source": [ + "import json\n", + "import time\n", + "import csv\n", + "\n", + "filename = '../item1.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/长炼医院人员2024(汇总).json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "filename = 'data/places_result_20241206.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_长炼医院人员2024(0417前).json'\n", + "\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl, ensure_ascii=False) \n", + "print(len(re_ta))" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "f2345606-fe1b-49d4-b99b-f94aeec593eb", + "id": "7583ad54-3e66-4ef8-ae51-f01eda2bf647", "metadata": {}, "outputs": [], "source": []