3051 lines
104 KiB
Plaintext
3051 lines
104 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "19280f5c-8e34-4a64-8dfb-6353cbf597d2",
|
|
"metadata": {
|
|
"tags": [],
|
|
"toc-hr-collapsed": true
|
|
},
|
|
"source": [
|
|
"# 体质检测数据处理"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "112d80f4-607b-41f9-bb30-ac2eb8f52ee2",
|
|
"metadata": {
|
|
"jp-MarkdownHeadingCollapsed": true,
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"## 基础数据管理"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9a06725f-248b-44dd-b029-c18e7c0689ee",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 体测数据按编号汇总"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "47aa588c-1880-44a8-add0-6fad777065d6",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"item = {}\n",
|
|
"bh = set()\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",
|
|
"list2 = []\n",
|
|
"rq = '20240612'\n",
|
|
"filename = f'data/places_result_{rq}.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",
|
|
" bh.add(line[2])\n",
|
|
" \n",
|
|
"#print(list1)\n",
|
|
"for result in list1:\n",
|
|
" user = str(result[2])\n",
|
|
" \n",
|
|
" m_item = str(result[3]) \n",
|
|
" re_ta.setdefault(user,{}) \n",
|
|
" \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",
|
|
"\n",
|
|
"\n",
|
|
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
|
"title = ['编号','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
|
"list1 = []\n",
|
|
"for k, v in re_ta.items():\n",
|
|
" list2 = []\n",
|
|
" list2.append(str(k))\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 = f'data/长炼医院体测情况表({rq}).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": "markdown",
|
|
"id": "b7dfd50f-a614-497d-8f0a-fa1e4c89168a",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 体测项目标准导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "8cd73044-56a8-409b-a873-085feb63af17",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\n",
|
|
"tcbz ={\n",
|
|
" 'HeightWeigh':'身高体重',\n",
|
|
" 'StepExperiment':'台阶指数',\n",
|
|
" 'Lung':'肺活量',\n",
|
|
" 'Proneness':'坐位体前屈',\n",
|
|
" 'PowerfullGrip':'握力',\n",
|
|
" 'OneMinutePushUp':'一分钟仰卧起坐',\n",
|
|
" 'PushUp':'俯卧撑',\n",
|
|
" 'VerticalJump':'纵跳',\n",
|
|
" 'ReactionTime':'选择反应时',\n",
|
|
" 'FootStand':'单脚站立'\n",
|
|
"}\n",
|
|
"wb = openpyxl.load_workbook('data/体质检测标准.xlsx')\n",
|
|
"sheet = wb.active\n",
|
|
"# sheets = wb.sheetnames\n",
|
|
"dict1 = {}\n",
|
|
"dict3 = {}\n",
|
|
"for k, v in tcbz.items():\n",
|
|
" dict3[v] = k\n",
|
|
"sheet = wb.active\n",
|
|
"data1 =list(sheet.values)\n",
|
|
"del data1[0]\n",
|
|
"for item in data1:\n",
|
|
" sex = item[0][6:]\n",
|
|
" if sex =='男':\n",
|
|
" age_sex = 'M'+item[0][:5]\n",
|
|
" else:\n",
|
|
" age_sex = 'F'+item[0][:5]\n",
|
|
" dict1.setdefault(age_sex,{})\n",
|
|
" if item[1] in dict3.keys():\n",
|
|
" xm = dict3[item[1]]\n",
|
|
" dict1[age_sex].setdefault(xm,[])\n",
|
|
" dict1[age_sex][xm].append(item[3]/item[4])\n",
|
|
"dict2 = {}\n",
|
|
"#print(dict1)\n",
|
|
"for k, v in dict1.items():\n",
|
|
" i1 = int(k[1:3])\n",
|
|
" i2 = int(k[-2:])\n",
|
|
" m_sex = k[:1]\n",
|
|
" for i in range(i1,i2+1):\n",
|
|
" dict2[m_sex+str(i)] = k\n",
|
|
"dict3 = {}\n",
|
|
"dict3['person'] = dict2\n",
|
|
"dict3['criteria'] = dict1\n",
|
|
"filename = 'data/体质检测标准.json'\n",
|
|
"with open(filename, 'w') as fl:\n",
|
|
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c36641d8-c54b-43d2-ad9d-ff4cb72deba9",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 身高标准导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2ca52d7b-d77e-452f-98f6-95072a5a1934",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\n",
|
|
"tcbz ={\n",
|
|
" 'HeightWeigh':'身高体重',\n",
|
|
" 'StepExperiment':'台阶指数',\n",
|
|
" 'Lung':'肺活量',\n",
|
|
" 'Proneness':'坐位体前屈',\n",
|
|
" 'PowerfullGrip':'握力',\n",
|
|
" 'OneMinutePushUp':'一分钟仰卧起坐',\n",
|
|
" 'PushUp':'俯卧撑',\n",
|
|
" 'VerticalJump':'纵跳',\n",
|
|
" 'ReactionTime':'选择反应时',\n",
|
|
" 'FootStand':'单脚站立'\n",
|
|
"}\n",
|
|
"wb = openpyxl.load_workbook('data/体质检测标准_BMI.xlsx')\n",
|
|
"sheet = wb.active\n",
|
|
"# sheets = wb.sheetnames\n",
|
|
"dict1 = {}\n",
|
|
"dict3 = {}\n",
|
|
"for k, v in tcbz.items():\n",
|
|
" dict3[v] = k\n",
|
|
"sheet = wb.active\n",
|
|
"data1 =list(sheet.values)\n",
|
|
"del data1[0]\n",
|
|
"for item in data1:\n",
|
|
" min_age = int(item[1]/12)\n",
|
|
" max_age = int((item[2]+1)/12) - 1\n",
|
|
" sex = item[0]\n",
|
|
" height = int(item[3])\n",
|
|
" if sex ==0:\n",
|
|
" age_sex = 'M'+str(min_age)+'~'+str(max_age)\n",
|
|
" else:\n",
|
|
" age_sex = 'F'+str(min_age)+'~'+str(max_age)\n",
|
|
" dict1.setdefault(age_sex,{})\n",
|
|
" \n",
|
|
" dict1[age_sex].setdefault(height,[])\n",
|
|
" dict1[age_sex][height].append(item[5]/1000)\n",
|
|
"dict2 = {}\n",
|
|
"#print(dict1)\n",
|
|
"for k, v in dict1.items():\n",
|
|
" i1 = int(k[1:3])\n",
|
|
" i2 = int(k[-2:])\n",
|
|
" m_sex = k[:1]\n",
|
|
" for i in range(i1,i2+1):\n",
|
|
" dict2[m_sex+str(i)] = k\n",
|
|
"dict3 = {}\n",
|
|
"dict3['person'] = dict2\n",
|
|
"dict3['criteria'] = dict1\n",
|
|
"filename = 'data/体质检测标准_BMI.json'\n",
|
|
"with open(filename, 'w') as fl:\n",
|
|
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ad5a702c-1503-463f-9d02-b78b881aad1b",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 生成项目信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "5071c245-3fdb-4c16-8f15-998af7c1d2fe",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"filename = '../item.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",
|
|
" del item[k]['divisor']\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",
|
|
"filename = 'data/体质检测项目信息.json'\n",
|
|
"with open(filename, 'w') as fl:\n",
|
|
" json.dump(item, fl, ensure_ascii=False)\n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "59f5708d-c2d0-4470-b2f4-b9face431865",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 计算分数"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "f32b266a-7e46-4703-ab61-7cbbc81b5ab1",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"filename = 'data/体质检测标准.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"person = dict1['person']\n",
|
|
"criteria = dict1['criteria']\n",
|
|
"data = {'name':'张三','sex':'M','age':37,'item':'StepExperiment','result':46}\n",
|
|
"info = data['sex']+str(data['age'])\n",
|
|
"bz = person[info]\n",
|
|
"mx = criteria[bz][data['item']]\n",
|
|
"result = data['result']\n",
|
|
"score = -1\n",
|
|
"print(mx)\n",
|
|
"for bz1 in mx:\n",
|
|
" if result < bz1:\n",
|
|
" print(bz1)\n",
|
|
" score = mx.index(bz1,0)\n",
|
|
" break\n",
|
|
" else:\n",
|
|
" score = 5\n",
|
|
"#if score == -1:\n",
|
|
" # score = 5\n",
|
|
"print(score)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "755f8b66-c71c-4138-bd12-dff24e85e36a",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 计算BMI分数"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "b32fbbdd-eb0a-4f0d-8901-e39a727c3ff8",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"filename = 'data/体质检测标准_BMI.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"person = dict1['person']\n",
|
|
"criteria = dict1['criteria']\n",
|
|
"data = {'name':'张三','sex':'M','age':37,'item':'HeightWeight','result':'177.7,97.0'}\n",
|
|
"info = data['sex']+str(data['age'])\n",
|
|
"\n",
|
|
"bz = person[info]\n",
|
|
"print(bz)\n",
|
|
"result = data['result']\n",
|
|
"print(result)\n",
|
|
"height = int(float(result.split(',')[0]))\n",
|
|
"weight = float(result.split(',')[1])\n",
|
|
"mx = criteria[bz][str(height)]\n",
|
|
"if weight < mx[0]:\n",
|
|
" score = 1\n",
|
|
"elif weight < mx[1]:\n",
|
|
" score = 3\n",
|
|
"elif weight < mx[2]:\n",
|
|
" score = 5 \n",
|
|
"elif weight <= mx[3]:\n",
|
|
" score = 3 \n",
|
|
"elif weight > mx[3]:\n",
|
|
" score = 1\n",
|
|
"print(score)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "7fe0ffe8-c3d1-4843-9765-87d4a12b7c39",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 体测报告生成"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9fec0bfc-8a97-446f-95fe-6e9cf8e482d8",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 转换报告格式"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "3e614f4a-a623-48e2-97f8-b31f62c9a983",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import datetime\n",
|
|
"import csv\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"filename = '../item.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/天津石化人员2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/places_result_20241104.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",
|
|
"print(len(re_ta))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "6741916c-deb6-496f-bc8f-5248e107e0e9",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 生成完善得分"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"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": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"ok!\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"\n",
|
|
"filename = '../item1.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict3 = json.load(fl) \n",
|
|
"for k,v in dict3.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",
|
|
"filename = 'data/体质检测标准 (1).json' \n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"def cal_score(data1):\n",
|
|
" #data = {'name':'张三','sex':'M','age':37,'item':'StepExperiment','result':46} \n",
|
|
" person = dict1['person']\n",
|
|
" criteria = dict1['criteria']\n",
|
|
" if data1['age'] >59:\n",
|
|
" data1['age'] = 59\n",
|
|
" if data1['age'] <20:\n",
|
|
" data1['age'] = 20\n",
|
|
" info = data1['sex']+str(data1['age'])\n",
|
|
" bz = person[info]\n",
|
|
" mx = criteria[bz][data1['item']]\n",
|
|
" result = data1['result'] \n",
|
|
" if data1['item'] == 'reaction':\n",
|
|
" for bz1 in mx:\n",
|
|
" if result > bz1:\n",
|
|
" #print(bz1)\n",
|
|
" score = mx.index(bz1,0)\n",
|
|
" break\n",
|
|
" else:\n",
|
|
" score = 5\n",
|
|
" else:\n",
|
|
" for bz1 in mx:\n",
|
|
" if result < bz1:\n",
|
|
" #print(bz1)\n",
|
|
" score = mx.index(bz1,0)\n",
|
|
" break\n",
|
|
" else:\n",
|
|
" score = 5\n",
|
|
" return(score)\n",
|
|
"filename = 'data/体质检测标准_BMI.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict4 = json.load(fl) \n",
|
|
" \n",
|
|
"def cal_bmi(data1):\n",
|
|
" # data = {'name':'张三','sex':'M','age':37,'item':'HeightWeight','result':'177.7,97.0'}\n",
|
|
" person = dict4['person']\n",
|
|
" criteria = dict4['criteria']\n",
|
|
" if data1['age'] > 59:\n",
|
|
" data1['age'] = 59\n",
|
|
" if data1['age'] <20:\n",
|
|
" data1['age'] = 20\n",
|
|
" info = data1['sex']+str(data1['age'])\n",
|
|
" bz = person[info]\n",
|
|
" #print(bz)\n",
|
|
" result = data1['result']\n",
|
|
" #print(data1['code'],result)\n",
|
|
" height = int(float(result.split(',')[0]))\n",
|
|
" weight = float(result.split(',')[1])\n",
|
|
" if str(height) not in criteria[bz]:\n",
|
|
" score = 1\n",
|
|
" else: \n",
|
|
" mx = criteria[bz][str(height)]\n",
|
|
" if weight < mx[0]:\n",
|
|
" score = 1\n",
|
|
" elif weight < mx[1]:\n",
|
|
" score = 3\n",
|
|
" elif weight < mx[2]:\n",
|
|
" score = 5 \n",
|
|
" elif weight <= mx[3]:\n",
|
|
" score = 3 \n",
|
|
" elif weight > mx[3]:\n",
|
|
" score = 1\n",
|
|
" return score\n",
|
|
" \n",
|
|
" \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_长炼医院人员2024(湖南青年).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 'height' in v.keys() and 'weight' in v.keys():\n",
|
|
" bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\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'] = 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",
|
|
" 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",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
|
"print('ok!') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ceef0742-f62a-4a7d-b0d5-be7ae7abb741",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 生成报告"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"id": "b123ee6b-85d2-4660-b226-321832a6b796",
|
|
"metadata": {
|
|
"execution": {
|
|
"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": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"78\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import requests\n",
|
|
"import json\n",
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"\n",
|
|
"headers = {\n",
|
|
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
|
" }\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",
|
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
|
"i=0\n",
|
|
"list2 = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" list1 = []\n",
|
|
" mydata = {}\n",
|
|
" \n",
|
|
" id = str(k).rjust(4,\"0\")\n",
|
|
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
|
|
" mydata['title'] = '中石化长岭分公司'\n",
|
|
" mydata['subtitle'] = v['unit']\n",
|
|
" mydata['id'] = id\n",
|
|
" mydata['name'] = v['name']\n",
|
|
" if v['sex'] == '男':\n",
|
|
" mydata['gender'] = 'male'\n",
|
|
" else:\n",
|
|
" mydata['gender'] = 'female'\n",
|
|
" \n",
|
|
" mydata['month'] = v['month']\n",
|
|
" mydata['fits'] = {}\n",
|
|
" survey_list = ['tcm','psy','spine']\n",
|
|
" for item in survey_list:\n",
|
|
" if item in v.keys():\n",
|
|
" mydata.setdefault('surveys',{})\n",
|
|
" mydata['surveys'][item] = v[item]\n",
|
|
" \n",
|
|
" \n",
|
|
" #mydata['fits'] = {}\n",
|
|
" for item in list_item:\n",
|
|
" if item in v.keys():\n",
|
|
" mydata.setdefault('fits',{})\n",
|
|
" if item in ['lung','pushup','step','situp']:\n",
|
|
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
|
" 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",
|
|
" list1.append(mydata)\n",
|
|
" list2.append([k,v['name']])\n",
|
|
" i+=1\n",
|
|
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
|
" #print(id,v['name'],x.text)\n",
|
|
" #print(mydata)\n",
|
|
" #x.close()\n",
|
|
"print(i)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4c1b3696-ab24-44bd-894a-e271ecfe4e38",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import requests\n",
|
|
"import json\n",
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"\n",
|
|
"headers = {\n",
|
|
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
|
" }\n",
|
|
"filename = 'data/result_东营工程设计院2024_all.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"list1 = []\n",
|
|
"file_path ='./中石化石油工程设计有限公司/'\n",
|
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
|
"i=0\n",
|
|
"list2 = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" list1 = []\n",
|
|
" mydata = {}\n",
|
|
" \n",
|
|
" id = str(k).rjust(4,\"0\")\n",
|
|
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
|
|
" mydata['title'] = '中石化石油工程设计有限公司'\n",
|
|
" mydata['subtitle'] = v['unit']\n",
|
|
" mydata['id'] = id\n",
|
|
" mydata['name'] = v['name']\n",
|
|
" if v['sex'] == '男':\n",
|
|
" mydata['gender'] = 'male'\n",
|
|
" else:\n",
|
|
" mydata['gender'] = 'female'\n",
|
|
" \n",
|
|
" mydata['month'] = v['month']\n",
|
|
" mydata['fits'] = {}\n",
|
|
" survey_list = ['tcm','psy','spine']\n",
|
|
" for item in survey_list:\n",
|
|
" if item in v.keys():\n",
|
|
" mydata.setdefault('surveys',{})\n",
|
|
" mydata['surveys'][item] = v[item]\n",
|
|
" \n",
|
|
" \n",
|
|
" #mydata['fits'] = {}\n",
|
|
" for item in list_item:\n",
|
|
" if item in v.keys():\n",
|
|
" mydata.setdefault('fits',{})\n",
|
|
" if item in ['lung','pushup','step','situp']:\n",
|
|
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
|
" 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",
|
|
" \n",
|
|
" list1.append(mydata)\n",
|
|
" list2.append([k,v['name']])\n",
|
|
" i+=1\n",
|
|
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
|
" #print(id,v['name'],x.text)\n",
|
|
" #print(mydata)\n",
|
|
" #x.close()\n",
|
|
"print(i)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "4642faf7-52bf-40e9-9af3-7555d4eef10b",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 体测报告按部门分类"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"id": "d913a531-51b3-4795-adc3-f4fc858d7401",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-12T07:37:15.387929Z",
|
|
"iopub.status.busy": "2024-12-12T07:37:15.387152Z",
|
|
"iopub.status.idle": "2024-12-12T07:37:15.525479Z",
|
|
"shell.execute_reply": "2024-12-12T07:37:15.524900Z",
|
|
"shell.execute_reply.started": "2024-12-12T07:37:15.387860Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"302\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0240049-陈晓辉.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001134-李和平.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526128-黎戬.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1984143-彭超.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526130-吴书鹏.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526186-周子瑄.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498058-柳聪.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001147-黄紫暄.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3125602-王凤.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526182-李基博.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983629-黄喜阳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983174-叶可.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001041-陈峥嵘.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983626-彭定荣.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001122-赵进.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001149-张嘉欣.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498083-陆杨.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1989523-周松林.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983534-蔡维.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245716-杨熙哲.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3125625-宋霰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002091-黄琪.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526143-廖成思.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002144-乔林臻.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002035-李南烽.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983832-李刚.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985478-刘志辉.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985639-陈强.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464129-谢倩.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985328-张建.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983771-李振宇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526134-刘晋炀.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437585-贺常霏.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526199-徐敬.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983569-谢俊杰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3413868-徐韩.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464103-彭旭涛.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464145-陈毅.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002037-饶军.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002116-胡敏.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001997-于明浩.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001145-戴玮兵.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001043-谢玉婷.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983740-万双华.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437581-李成伟.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001076-荣贇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3358823-黎贤贞智.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001128-欧阳雅馨.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3413865-孟繁荣.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3535865-王明珠.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437567-朱雨晴.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001036-陈怀至.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001993-陈杰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464097-孙颖.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464138-陈兰鑫.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001718-巴银花儿.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001115-吴梦瑶.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3170676-常硕.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001010-邱亮.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1989522-钟建东.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001133-彭宇博.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001096-温家祥.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983844-彭鑫.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985485-张瑞.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983866-倪博.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1993388-蒋莉.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3170724-张翔.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001020-贾俊.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1989709-卞伟.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001092-钟兴阳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983770-黄刚.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001114-曾子坤.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985926-宁佐强.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437574-胡颖.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983836-陈文辉.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526185-方劲松.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3281543-谢崴.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983837-罗文武.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985666-李思.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526180-李今朝.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3281536-王智浩.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498029-汤思煜.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001860-李晨阳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983800-郭丽梅.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002023-梁军.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437557-周念.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001053-刘志刚.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3497994-黄博轩.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002043-邓余斌.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983785-胡湘.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001144-黄英杰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3535506-田子豪.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983775-胡向民.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985551-吴敏.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526176-万航.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001119-汤艳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464081-刘权.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3358822-黎明.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1987904-李佳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985913-毛智勇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464205-胡雨丹.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001012-吴磊.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526187-夏堃喻.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3413857-仇乐.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464122-眭永波.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526177-周晏本.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983661-李静.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3160188-冯军.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498042-赵天宇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983797-周辉灿.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3139284-全世夷.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498031-吴义.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3319096-毛润政.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3358812-邵昌睿.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001130-许竹新.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985287-陈宝林.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985440-吴阳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001069-李鑫.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001032-吴志祚.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3319086-唐子涵.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3503272-董晨阳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498000-陈旭.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3319099-肖博文.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498059-李慧慧.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001028-李蓝蓝.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001034-严雅珂.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1989710-谭珂屿.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002056-江汇涛.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245723-祝恒兴.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526154-陈柳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001141-张俊凡.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983622-胡诗学.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526170-杨龙姣.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001093-李欣怡.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001078-张薇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001058-杨红.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983830-刘军.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245709-姚佩.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002036-胡杰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983180-张毅.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983143-吴巍.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983100-余益波.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245733-高帆.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985907-毛卫群.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526135-高斯阳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002159-丁杰涛.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983171-王复兴.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983109-谈志亮.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526127-郭倩颖.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983652-向彭.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464069-于业晟.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526189-施陈心.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1986007-李明权.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464134-陈亮.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002100-彭晨雨.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001072-薛苗.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001121-张蕾.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002004-刘敏明.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001040-向安平.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3503276-熊东.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001023-彭一夫.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1992225-叶忠良.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3358818-鲁轩熠.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985356-黄超.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983119-经永华.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985324-谢清峰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498065-刘雍涵.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983530-鲁世俊.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3281551-黄杰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001070-黄辅君.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983108-张新芬.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526165-刘至清.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001073-翟秋霞.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985891-王定鲜.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526156-袁子灿.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001074-陈佳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464077-冯晓阳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983635-刘飞.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001031-高浩然.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498028-刘明泽.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3427189-段威.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002115-张丽军.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983159-李华锐.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983759-闵敢.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001132-李颖.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001079-袁丽雯.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983322-张健.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3125613-李青.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002114-唐景柳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001029-邓韧泰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498091-花慧.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985673-刘国东.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001146-方娜.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002122-周瑜.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245719-王宁.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001048-谢浩.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983777-谢林.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985611-丁敏.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002176-张嫚.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1986235-郑小芳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001120-薛美佳.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001046-汤茜.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3139304-王卓见.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983107-沈高峰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245735-黎金龙.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983846-廖念.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3319087-孟凡澄.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464084-吴煜文.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983106-罗鸣.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983823-甘龙.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001057-彭菲.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001052-陈祥宇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001059-罗嘉俊.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002039-胡荣华.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464198-陈世博.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001098-刘夏俐.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001143-卢章凌.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001084-周博.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526193-李可.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3281545-贺凯.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526179-李博.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1989539-唐韵辅.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983557-涂彬.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001039-王鹏.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983831-黄波.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498023-戴汉林.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983779-高建华.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001065-涂俐.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983863-张勇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985621-杨大为.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985698-李开俊.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245725-贺飞.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001044-李德文.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001870-龚斯壮.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245717-汪洋.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002166-张梦圆.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498020-倪炜强.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001050-马一文.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001027-向雅婷.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002126-蔡安逸.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3281530-吴征宇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983683-李杜娟.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983630-龚付金.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498004-江载舟.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001045-李尉铭.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001049-曾洪.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3125609-张哲.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3319101-袁楚云.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3281544-谢思遥.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1989487-彭华明.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526147-黄天舒.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3394214-唐金滔.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001001-梅小龙.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1993242-何东海.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002067-黄建生.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498061-马璐.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3503275-邓野.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001033-邹雪平.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464164-刘雨薇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498033-陈雅玲.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983595-侯代磊.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001095-江欢.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001087-阳涛.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001051-任藩韬.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1961098-武文娟.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001091-黄南.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3170725-赵雨龙.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983758-任珍琦.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3358815-陈海.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001042-杨宇凡.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983767-刘林波.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3245700-刘细.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983799-彭宇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001038-彭健霖.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498055-陶汝.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464200-马婷.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983868-彭国强.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002151-李美玲.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983176-李关亮.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1993413-汤愉.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464165-向嘉伟.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1987427-谢小飞.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498044-张坚发.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3160187-邹尚辰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001060-郭凌宇.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437569-李湘川.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498089-邹竞莹.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983965-文智.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498080-颜艳萍.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002063-杨杰.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001148-张兰心.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3526138-于润韬.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437554-刘毅.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985838-郭汨.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3498063-游胜利.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1985615-喻永强.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3464148-黎泓松.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/1983262-杨淼君.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001085-刘海燕.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0001112-汤超.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/0002124-唐睿.pdf\n",
|
|
"/home/songyi/pdf-typescript/长炼医院2024/3437578-黄晓平.pdf\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import os,sys,shutil\n",
|
|
"import json\n",
|
|
"import glob\n",
|
|
"from pathlib import Path\n",
|
|
"\n",
|
|
"fi_path = '/home/songyi/pdf-typescript/长炼医院2024'\n",
|
|
"new_path = 'file/长炼医院2024'\n",
|
|
"old = []\n",
|
|
"dict2 = {}\n",
|
|
"\n",
|
|
"filename = 'data/result_长炼医院人员2024(汇总).json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
|
"print(len(fls))\n",
|
|
"for fn in fls:\n",
|
|
" fi_name =Path(fn).stem.split('-')[0]\n",
|
|
" code = int(fi_name) \n",
|
|
" unit_path = Path(new_path,dict1[str(code)]['unit'])\n",
|
|
" unit_path.mkdir(parents = True, exist_ok = True)\n",
|
|
" n_name = Path(unit_path,Path(fn).stem+'.pdf')\n",
|
|
" #if not os.path.exists(n_name):\n",
|
|
" shutil.copyfile(fn,n_name)\n",
|
|
" print(fn)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "1e6ece92-7845-49df-a84c-88a2befee570",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成体测报告打印明细表"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 21,
|
|
"id": "02319955-7fb6-4791-ae45-55b03bdadd54",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-12T07:41:07.877091Z",
|
|
"iopub.status.busy": "2024-12-12T07:41:07.876276Z",
|
|
"iopub.status.idle": "2024-12-12T07:41:07.919596Z",
|
|
"shell.execute_reply": "2024-12-12T07:41:07.919038Z",
|
|
"shell.execute_reply.started": "2024-12-12T07:41:07.877012Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"ok\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import os,sys,shutil\n",
|
|
"import json\n",
|
|
"import glob\n",
|
|
"from pathlib import Path\n",
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"fi_path = '/home/songyi/pdf-typescript/长炼医院2024'\n",
|
|
"\n",
|
|
"filename = 'data/result_长炼医院人员2024(汇总).json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
|
"list1 = []\n",
|
|
"title = ['测试编号','姓名','性别','部门']\n",
|
|
"for fn in fls:\n",
|
|
" list2 = []\n",
|
|
" fi_name =Path(fn).stem.split('-')[0] \n",
|
|
" code = int(fi_name)\n",
|
|
" sex = dict1[str(code)]['sex']\n",
|
|
" unit = dict1[str(code)]['unit']\n",
|
|
" list2 = [fi_name,Path(fn).stem.split('-')[1],sex,unit]\n",
|
|
" \n",
|
|
" list1.append(list2)\n",
|
|
"\n",
|
|
"filename = 'data/长炼医院2024年体测报告明细表.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) \n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "34ef7e0d-35ea-4739-a1cb-540c5039afb7",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 检查报告错误人员"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c464fa11-8a0d-44e9-8af0-8c1f50263ceb",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os,sys,shutil\n",
|
|
"import json\n",
|
|
"import glob\n",
|
|
"from pathlib import Path\n",
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"fi_path = '/home/songyi/pdf-typescript/北海炼化2024'\n",
|
|
"\n",
|
|
"filename = 'data/result_北海炼化2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"print(len(dict1))\n",
|
|
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
|
"list1 = []\n",
|
|
"for fn in fls: \n",
|
|
" fi_name =Path(fn).stem.split('-')[0] \n",
|
|
" code = int(fi_name)\n",
|
|
" list1.append(str(code))\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if k not in list1:\n",
|
|
" print(k)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "732161bb-98f2-4861-ab66-7a374678bcd8",
|
|
"metadata": {
|
|
"tags": [],
|
|
"toc-hr-collapsed": true
|
|
},
|
|
"source": [
|
|
"# 体质检测数据管理"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "bb2db5e8-5dc6-4366-a39c-a3600ee5007c",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 数据导入Mycrm"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "bc98d772-5841-41a3-ad8f-f7d1ff3b5fde",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导入系统人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2cd93f45-6613-4a3f-97e4-5236068e1860",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"list1 = []\n",
|
|
"filename = 'data/person_134.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",
|
|
"dict1 = {}\n",
|
|
"for result in list1:\n",
|
|
" code = str(result[4])\n",
|
|
" if int(result[1]) == 0:\n",
|
|
" sex = '男'\n",
|
|
" else:\n",
|
|
" sex = '女'\n",
|
|
" \n",
|
|
" m_item = str(result[3]) \n",
|
|
" dict1.setdefault(code,{}) \n",
|
|
" dict1[code]['name'] = result[0]\n",
|
|
" dict1[code]['sex'] = sex\n",
|
|
" dict1[code]['birth'] = result[2]\n",
|
|
"filename = 'data/天津石化人员清单.json'\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl, ensure_ascii=False) \n",
|
|
"print(len(dict1)) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2eb50f19-c15f-4a36-87b7-cd02551d248d",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导入测试项目item"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "0eb37435-9c15-40ef-bd4c-2dffc026f59e",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"data_list = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" data_list.append((int(k),v['name'])) \n",
|
|
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
|
|
"cursor = conn.cursor()\n",
|
|
"sql = 'insert into shijiazhuang_item (id,name) values %s'\n",
|
|
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
|
|
"#conn.commit()\n",
|
|
"cursor.close()\n",
|
|
"conn.close()\n",
|
|
"print('ok!')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2ba97298-1e7e-4192-8d69-ea59f98e071a",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导入一级部门"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9f7ed380-95f3-47d4-9eb5-74937af7811f",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
|
|
"cursor = conn.cursor()\n",
|
|
"filename = 'data/result_石家庄.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"unit = set()\n",
|
|
"for k, v in dict1.items():\n",
|
|
" #if 'sub_unit' not in v.keys():\n",
|
|
" # print(k,v['name'])\n",
|
|
" unit.add(v['unit'])\n",
|
|
"print(unit) \n",
|
|
"i = 1\n",
|
|
"dict2 = {}\n",
|
|
"for item in unit:\n",
|
|
" dict2[item] = i\n",
|
|
" i+=1\n",
|
|
"data_list = []\n",
|
|
"for k, v in dict2.items():\n",
|
|
" data_list.append((v,k)) \n",
|
|
" \n",
|
|
"sql = 'insert into shijiazhuang_unit (id,name) values %s'\n",
|
|
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
|
|
"#conn.commit()\n",
|
|
"cursor.close()\n",
|
|
"conn.close()\n",
|
|
"print('ok!')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "b8a1fa7f-08ff-49bb-8052-9f86b1f2ac18",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导入二级部门"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a13e81f2-467f-42c7-bb46-b547ef7bdd6c",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
|
|
"cursor = conn.cursor()\n",
|
|
"filename = 'data/天津石化人员名单.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"unit = set()\n",
|
|
"for k, v in dict1.items():\n",
|
|
" #if 'sub_unit' not in v.keys():\n",
|
|
" # print(k,v['name'])\n",
|
|
" unit.add(v['unit'])\n",
|
|
"print(unit) \n",
|
|
"i = 1\n",
|
|
"dict2 = {}\n",
|
|
"for item in unit:\n",
|
|
" dict2[item] = i\n",
|
|
" i+=1\n",
|
|
"data_list = []\n",
|
|
"dict3 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict3.setdefault(v['unit'],set())\n",
|
|
" dict3[v['unit']].add(v['sub_unit'])\n",
|
|
"i = 1 \n",
|
|
"for k, v in dict3.items():\n",
|
|
" unit_id = dict2[k]\n",
|
|
" for item in v:\n",
|
|
" data_list.append((i,item,unit_id))\n",
|
|
" i+=1\n",
|
|
"sql = 'insert into tianjin_sub_unit (id,name,unit_id) values %s'\n",
|
|
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
|
|
"#conn.commit()\n",
|
|
"cursor.close()\n",
|
|
"conn.close()\n",
|
|
"print('ok!')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "12917000-59e0-4f8a-beee-929c6d7b60a0",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 生成部门JSON文件"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "5446269c-d324-4a16-b10e-f24d87178d77",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"dict1 = {}\n",
|
|
"filename = 'data/shijiazhuang_unit_20230517.csv'\n",
|
|
"with open(filename,'r',newline='') as csv_file:\n",
|
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
|
" header = next(fl)\n",
|
|
" list1 = []\n",
|
|
" for line in fl:\n",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append({'id':int(line[0]),'name':line[1]})\n",
|
|
"dict1['unit'] = list1\n",
|
|
"\n",
|
|
"filename = 'data/sub_unit_134.csv'\n",
|
|
"with open(filename,'r',newline='') as csv_file:\n",
|
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
|
" header = next(fl)\n",
|
|
" list1 = []\n",
|
|
" for line in fl:\n",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append({'id':int(line[0]),'name':line[1],'unit_id':int(line[2])})\n",
|
|
"dict1['sub_unit'] = list1\n",
|
|
"print(dict1)\n",
|
|
"\n",
|
|
"filename = 'data/天津石化部门.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": "5e57329d-a0ef-47b2-9866-fe2a911ff01d",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"dict1 = {}\n",
|
|
"filename = 'data/shijiazhuang_unit_20230517.csv'\n",
|
|
"with open(filename,'r',newline='') as csv_file:\n",
|
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
|
" header = next(fl)\n",
|
|
" list1 = []\n",
|
|
" for line in fl:\n",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append({'id':int(line[0]),'name':line[1]})\n",
|
|
" dict1[int(line[0])] = line[1]\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/石家庄石化部门.json'\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl, ensure_ascii=False) \n",
|
|
"print(len(dict1)) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "53bf98fe-0ae9-402f-b8d8-495e8f31df3d",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导入人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6af82fd2-b1d6-44b7-8b13-58883b58f8b0",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
|
|
"cursor = conn.cursor()\n",
|
|
"filename = 'data/天津石化人员清单.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" person = json.load(fl)\n",
|
|
" \n",
|
|
"filename = 'data/石家庄石化部门.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"i = 1\n",
|
|
"dict2 = {}\n",
|
|
"for item in unit:\n",
|
|
" dict2[item] = i\n",
|
|
" i+=1\n",
|
|
"data_list = []\n",
|
|
"dict3 = {}\n",
|
|
"dict4 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict3.setdefault(v['unit'],set())\n",
|
|
" dict3[v['unit']].add(v['sub_unit']) \n",
|
|
"i = 1 \n",
|
|
"for k, v in dict3.items():\n",
|
|
" unit_id = dict2[k]\n",
|
|
" for item in v:\n",
|
|
" data_list.append((i,item,unit_id))\n",
|
|
" i+=1\n",
|
|
"for item in data_list:\n",
|
|
" sub_id = item[0]\n",
|
|
" dict4[sub_id] = {'name':item[1],'unit':item[2]}\n",
|
|
"dict5 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" id_unit = dict2[v['unit']]\n",
|
|
" sub_name = v['sub_unit']\n",
|
|
" id_sub = 0\n",
|
|
" for k1, v1 in dict4.items():\n",
|
|
" if v1['name'] == sub_name and v1['unit'] == id_unit:\n",
|
|
" id_sub = int(k1)\n",
|
|
" if id_sub >0:\n",
|
|
" dict5[k] = {'unit':id_unit,'sub_unit':id_sub}\n",
|
|
" else:\n",
|
|
" print(k,'not fund')\n",
|
|
"data_list = []\n",
|
|
"for k, v in dict5.items():\n",
|
|
" id = int(k)\n",
|
|
" name = person[k]['name']\n",
|
|
" sex = person[k]['sex']\n",
|
|
" birth = person[k]['birth']\n",
|
|
" phone = ''\n",
|
|
" note = ''\n",
|
|
" unit = v['sub_unit']\n",
|
|
" data_list.append((id,name,sex,birth,unit))\n",
|
|
"sql = 'insert into tianjin_person (id,name,sex,birth,unit_id) values %s'\n",
|
|
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
|
|
"#conn.commit()\n",
|
|
"cursor.close()\n",
|
|
"conn.close()\n",
|
|
"print('ok!') \n",
|
|
" "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c2007c46-38c8-4a20-9917-b0b8743fe2a9",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
|
|
"cursor = conn.cursor()\n",
|
|
" \n",
|
|
"filename = 'data/石家庄石化部门.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"dict3 = {}\n",
|
|
"for k,v in dict1.items():\n",
|
|
" dict3[v] = int(k)\n",
|
|
"filename = 'data/result_石家庄.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict2 = json.load(fl)\n",
|
|
"data_list = []\n",
|
|
"for k, v in dict2.items():\n",
|
|
" id = int(k)\n",
|
|
" name = dict2[k]['name']\n",
|
|
" sex = dict2[k]['sex']\n",
|
|
" birth = dict2[k]['birth'] \n",
|
|
" unit = dict3[dict2[k]['unit']]\n",
|
|
" data_list.append((id,name,sex,birth,unit))\n",
|
|
"sql = 'insert into shijiazhuang_person (id,name,sex,birth,unit_id) values %s'\n",
|
|
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
|
|
"#conn.commit()\n",
|
|
"cursor.close()\n",
|
|
"conn.close()\n",
|
|
"print('ok!') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "fd95a45a-c6df-47c3-9941-2d0579b2c5d9",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导入测试成绩及得分"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c989de3f-a8ab-47dc-9662-544e4b6a0e2f",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"#### 二级部门导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "360e61e9-7895-484b-a9d6-333bdefa1a86",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"dict2 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict2[v['name']] = int(k)\n",
|
|
"\n",
|
|
"filename = 'data/天津石化部门.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"unit = {}\n",
|
|
"for item in dict1['unit']:\n",
|
|
" unit[item['name']] = item['id']\n",
|
|
"\n",
|
|
"sub_unit = {}\n",
|
|
"for item in dict1['sub_unit']:\n",
|
|
" sub_unit.setdefault(item['unit_id'],[])\n",
|
|
" sub_unit[item['unit_id']].append({'id':item['id'],'name':item['name']})\n",
|
|
" \n",
|
|
"filename = 'data/天津石化人员名单.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"person = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" person[k] = {'unit':v['unit'],'sub_unit':v['sub_unit']}\n",
|
|
"\n",
|
|
" \n",
|
|
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
|
|
"cursor = conn.cursor()\n",
|
|
"data_list = []\n",
|
|
"filename = 'data/result_天津.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k, v in dict1.items():\n",
|
|
" for item in v.keys():\n",
|
|
" if item in dict2.keys():\n",
|
|
" item_id = dict2[item]\n",
|
|
" if v[item]['得分'] == '\\\\N':\n",
|
|
" score = None\n",
|
|
" else:\n",
|
|
" score = int(v[item]['得分'])\n",
|
|
" unit_name = person[k]['unit'] \n",
|
|
" sub_unit_name = person[k]['sub_unit']\n",
|
|
" unit_id = unit[unit_name]\n",
|
|
" for items in sub_unit[unit_id]:\n",
|
|
" if items['name'] ==sub_unit_name:\n",
|
|
" sub_id = items['id'] \n",
|
|
" data_list.append((v[item]['成绩'],score,int(k),item_id,unit_id,sub_id))\n",
|
|
" \n",
|
|
"sql = 'insert into tianjin_records (performance,score,avatar_id_id,item_id_id,unit_id_id,sub_unit_id_id) values %s'\n",
|
|
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
|
|
"#conn.commit()\n",
|
|
"cursor.close()\n",
|
|
"conn.close()\n",
|
|
"print('ok!') \n",
|
|
" "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "4aeabbbc-5b51-4dd0-b428-83e2012e63c4",
|
|
"metadata": {},
|
|
"source": [
|
|
"#### 一级部门导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "cb747368-d3ac-4b29-ae4f-ce207d5fcd43",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"dict2 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict2[v['name']] = int(k)\n",
|
|
"\n",
|
|
"filename = 'data/石家庄石化部门.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"dict3 = {}\n",
|
|
"for k,v in dict1.items():\n",
|
|
" dict3[v] = int(k)\n",
|
|
" \n",
|
|
"\n",
|
|
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
|
|
"cursor = conn.cursor()\n",
|
|
"data_list = []\n",
|
|
"filename = 'data/result_石家庄.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k, v in dict1.items():\n",
|
|
" for item in v.keys():\n",
|
|
" if item in dict2.keys():\n",
|
|
" item_id = dict2[item] \n",
|
|
" if v[item]['得分'] == '':\n",
|
|
" score = None\n",
|
|
" else:\n",
|
|
" score = int(v[item]['得分'])\n",
|
|
" unit_name = v['unit']\n",
|
|
" unit_id = dict3[unit_name]\n",
|
|
" data_list.append((v[item]['成绩'],score,int(k),item_id,unit_id))\n",
|
|
"sql = 'insert into shijiazhuang_records (performance,score,avatar_id_id,item_id_id,unit_id_id) values %s'\n",
|
|
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
|
|
"#conn.commit()\n",
|
|
"cursor.close()\n",
|
|
"conn.close()\n",
|
|
"print('ok!')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "51dc35a5-dc07-40a4-9ea7-375ca7f983c3",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import psycopg2\n",
|
|
"from psycopg2 import extras as ex\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"dict2 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict2[v['name']] = int(k)\n",
|
|
"\n",
|
|
"filename = 'data/天津石化部门.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"unit = {}\n",
|
|
"for item in dict1['unit']:\n",
|
|
" unit[item['name']] = item['id']\n",
|
|
"print(unit)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "5780368e-59c7-4bc1-a130-21b2f7da23de",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 体质测试综合报告数据分析"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0ddf1a23-5963-43ba-9166-c88be749d75d",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 清理报告数据"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "46aa847d-e1fe-45bd-85b6-e2d792ec8842",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:27:58.141604Z",
|
|
"iopub.status.busy": "2024-12-20T07:27:58.140897Z",
|
|
"iopub.status.idle": "2024-12-20T07:27:58.343114Z",
|
|
"shell.execute_reply": "2024-12-20T07:27:58.342694Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:27:58.141536Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"301\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/result_长炼医院人员2024(汇总).json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
" \n",
|
|
"#items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
|
"items = {}\n",
|
|
"items['lung'] = '肺活量'\n",
|
|
"items['grip'] ='握力'\n",
|
|
"items['flexion'] ='坐位体前屈'\n",
|
|
"items['jump'] ='纵跳'\n",
|
|
"items['pushup'] ='俯卧撑'\n",
|
|
"items['balance'] ='单脚站立'\n",
|
|
"items['reaction'] ='选择反应时'\n",
|
|
"items['step'] ='台阶指数'\n",
|
|
"items['situp'] ='一分钟仰卧起坐'\n",
|
|
"items['bmi'] ='BMI'\n",
|
|
"\n",
|
|
"\n",
|
|
"list1 = []\n",
|
|
"#fiie_path ='./138/'\n",
|
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
|
"i=1\n",
|
|
"list2 = []\n",
|
|
"dict2 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" list1 = []\n",
|
|
" mydata = {}\n",
|
|
" \n",
|
|
" id = str(k).rjust(8,\"0\")\n",
|
|
" mydata['unit'] = v['unit']\n",
|
|
" mydata['name'] = v['name']\n",
|
|
" mydata['sex'] = v['sex']\n",
|
|
" mydata['month'] = v['month']\n",
|
|
" age = int(v['month']/12)\n",
|
|
" if age <20:\n",
|
|
" mydata['age'] = 20\n",
|
|
" else:\n",
|
|
" mydata['age'] = int(v['month']/12)\n",
|
|
" \n",
|
|
" mydata['fits'] = {}\n",
|
|
" score = 0\n",
|
|
" for item in list_item:\n",
|
|
" if item in v.keys():\n",
|
|
" if item in ['lung','pushup','step','situp']:\n",
|
|
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
|
" else:\n",
|
|
" mark = v[item]['成绩'].split()[0]\n",
|
|
" mydata['fits'][items[item]] = {'mark':mark,'score':v[item]['score']}\n",
|
|
" score = score + v[item]['score']\n",
|
|
" mydata['score'] = round(score/len(mydata['fits']),2)\n",
|
|
" if len(mydata['fits']) >2:\n",
|
|
" dict2[str(k)] = mydata\n",
|
|
"filename = f'data/data_长炼医院人员2024(汇总).json'\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
|
"print(len(dict2)) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ed5f157a-3114-4221-907d-53ce62409d83",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算平均成绩"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "63edd636-f034-4aa6-8575-63d5cdb84adb",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:28:13.394921Z",
|
|
"iopub.status.busy": "2024-12-20T07:28:13.394348Z",
|
|
"iopub.status.idle": "2024-12-20T07:28:13.405910Z",
|
|
"shell.execute_reply": "2024-12-20T07:28:13.405307Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:28:13.394870Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"平均成绩:2.7497分,男性:223人\n",
|
|
"平均成绩:2.9819分,女性:78人\n",
|
|
"平均成绩:2.8099分,总体:301人\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
|
|
"filename = 'data/data_长炼医院人员2024(汇总).json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"i = 1\n",
|
|
"m = 0\n",
|
|
"f = 0\n",
|
|
"score = 0\n",
|
|
"t_score = 0\n",
|
|
"for k,v in dict1.items():\n",
|
|
" if v['sex'] == '男':\n",
|
|
" m = m +1\n",
|
|
" score = score+v['score']\n",
|
|
"print(f'平均成绩:{round(score/m,4)}分,男性:{m}人')\n",
|
|
"t_score = t_score + score\n",
|
|
"score = 0\n",
|
|
"for k,v in dict1.items():\n",
|
|
" if v['sex'] == '女':\n",
|
|
" f = f +1\n",
|
|
" score = score+v['score']\n",
|
|
"print(f'平均成绩:{round(score/f,4)}分,女性:{f}人')\n",
|
|
"t_score = t_score + score\n",
|
|
"print(f'平均成绩:{round(t_score/(f+m),4)}分,总体:{(f+m)}人')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "3277b104-9b53-41c4-9b9a-f9acb71dbce1",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算测试等级"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "1b4a3f02-9b2e-41fc-ac6c-8163907a07f1",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:30:11.095892Z",
|
|
"iopub.status.busy": "2024-12-20T07:30:11.095122Z",
|
|
"iopub.status.idle": "2024-12-20T07:30:11.117663Z",
|
|
"shell.execute_reply": "2024-12-20T07:30:11.117077Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:30:11.095822Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"0~255分人数:91人,男性:79人,女性:12人\n",
|
|
"256~332分人数:143人,男性:100人,女性:43人\n",
|
|
"333~367分人数:47人,男性:30人,女性:17人\n",
|
|
"368~500分人数:20人,男性:14人,女性:6人\n",
|
|
"301\n",
|
|
"ok\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
|
"\n",
|
|
"#filename = 'data/data_长炼医院.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"dict2 = {}\n",
|
|
"dict2['不合格'] = [0,255]\n",
|
|
"dict2['合格'] = [256,332]\n",
|
|
"dict2['良好'] = [333,367]\n",
|
|
"dict2['优秀'] = [368,500]\n",
|
|
"\n",
|
|
"for k1, v1 in dict2.items():\n",
|
|
" di = v1[0]\n",
|
|
" gao = v1[1]\n",
|
|
" i = 0 \n",
|
|
" m = 0\n",
|
|
" f = 0\n",
|
|
" for k,v in dict1.items():\n",
|
|
" if int(v['score']*100) in range(di,gao+1):\n",
|
|
" dict1[k]['level'] = k1\n",
|
|
" i+=1\n",
|
|
" if v['sex'] == '男':\n",
|
|
" m = m +1\n",
|
|
" else:\n",
|
|
" f = f+1\n",
|
|
" print(f'{di}~{gao}分人数:{i}人,男性:{m}人,女性:{f}人')\n",
|
|
"print(len(dict1))\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl) \n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "39a1239d-13d8-4583-a163-e6db98c3933b",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 计算各年龄段测试等级(女)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "2d661ca6-6129-4da1-ac25-51d0156babb2",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:30:36.266609Z",
|
|
"iopub.status.busy": "2024-12-20T07:30:36.266057Z",
|
|
"iopub.status.idle": "2024-12-20T07:30:36.276604Z",
|
|
"shell.execute_reply": "2024-12-20T07:30:36.275720Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:30:36.266557Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"20-24 {'不合格': 7, '良好': 4, '优秀': 2, '合格': 17}\n",
|
|
"25-29 {'合格': 16, '不合格': 3, '良好': 6, '优秀': 1}\n",
|
|
"30-34 {'合格': 1, '优秀': 1, '不合格': 1, '良好': 2}\n",
|
|
"35-39 {'不合格': 0, '合格': 2, '良好': 1, '优秀': 1}\n",
|
|
"40-44 {'合格': 1, '不合格': 1, '良好': 2, '优秀': 0}\n",
|
|
"45-49 {'良好': 2, '合格': 5, '不合格': 0, '优秀': 1}\n",
|
|
"50-54 {'良好': 0, '合格': 1, '优秀': 0, '不合格': 0}\n",
|
|
"55-80 {'良好': 0, '合格': 0, '不合格': 0}\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
|
|
"\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"dict2 = {}\n",
|
|
"dict2['不合格'] = [0,255]\n",
|
|
"dict2['合格'] = [256,332]\n",
|
|
"dict2['良好'] = [333,367]\n",
|
|
"dict2['优秀'] = [368,500]\n",
|
|
"dict3 = {}\n",
|
|
"for item in nld:\n",
|
|
" di = item[0]\n",
|
|
" gao = item[1]\n",
|
|
" age = f'{di}-{gao}'\n",
|
|
" dict3.setdefault(age,{})\n",
|
|
" i = 0 \n",
|
|
" m = 0\n",
|
|
" f = 0\n",
|
|
" for k,v in dict1.items():\n",
|
|
" if v['age'] in range(di,gao+1): \n",
|
|
" dict3[age].setdefault(v['level'],0)\n",
|
|
" if v['sex'] == '女':\n",
|
|
" dict3[age][v['level']] = dict3[age][v['level']]+1\n",
|
|
" \n",
|
|
"for k, v in dict3.items():\n",
|
|
" print(k,v)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "b7d10bef-405f-49a1-b423-2b972b4d1a44",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 计算各年龄段测试等级(男)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "fc97df37-34ff-4a02-9d26-b5d81b706e46",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:30:38.696485Z",
|
|
"iopub.status.busy": "2024-12-20T07:30:38.695765Z",
|
|
"iopub.status.idle": "2024-12-20T07:30:38.711240Z",
|
|
"shell.execute_reply": "2024-12-20T07:30:38.710163Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:30:38.696422Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"20-24 {'不合格': 28, '良好': 7, '优秀': 1, '合格': 26}\n",
|
|
"25-29 {'合格': 18, '不合格': 17, '良好': 1, '优秀': 0}\n",
|
|
"30-34 {'合格': 10, '优秀': 2, '不合格': 11, '良好': 4}\n",
|
|
"35-39 {'不合格': 8, '合格': 13, '良好': 7, '优秀': 5}\n",
|
|
"40-44 {'合格': 10, '不合格': 3, '良好': 3, '优秀': 1}\n",
|
|
"45-49 {'良好': 4, '合格': 12, '不合格': 8, '优秀': 1}\n",
|
|
"50-54 {'良好': 2, '合格': 8, '优秀': 4, '不合格': 2}\n",
|
|
"55-80 {'良好': 2, '合格': 3, '不合格': 2}\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
|
|
"\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"dict2 = {}\n",
|
|
"dict2['不合格'] = [0,255]\n",
|
|
"dict2['合格'] = [256,332]\n",
|
|
"dict2['良好'] = [333,367]\n",
|
|
"dict2['优秀'] = [368,500]\n",
|
|
"dict3 = {}\n",
|
|
"for item in nld:\n",
|
|
" di = item[0]\n",
|
|
" gao = item[1]\n",
|
|
" age = f'{di}-{gao}'\n",
|
|
" dict3.setdefault(age,{})\n",
|
|
" i = 0 \n",
|
|
" m = 0\n",
|
|
" f = 0\n",
|
|
" for k,v in dict1.items():\n",
|
|
" if v['age'] in range(di,gao+1): \n",
|
|
" dict3[age].setdefault(v['level'],0)\n",
|
|
" if v['sex'] == '男':\n",
|
|
" dict3[age][v['level']] = dict3[age][v['level']]+1\n",
|
|
" \n",
|
|
"for k, v in dict3.items():\n",
|
|
" print(k,v)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "466355fe-5939-463c-a31e-a3a1beb4e78b",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 根据年龄汇总人员信息及成绩"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"id": "dafb86f8-5ee0-4c87-a98f-c7ff0f631fe5",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:31:09.731948Z",
|
|
"iopub.status.busy": "2024-12-20T07:31:09.731194Z",
|
|
"iopub.status.idle": "2024-12-20T07:31:09.742741Z",
|
|
"shell.execute_reply": "2024-12-20T07:31:09.741604Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:31:09.731880Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"16~24岁平均成绩:2.69分,人数:92人,男性:62人\n",
|
|
"25~29岁平均成绩:2.72分,人数:62人,男性:36人\n",
|
|
"30~34岁平均成绩:2.75分,人数:32人,男性:27人\n",
|
|
"35~39岁平均成绩:3.04分,人数:37人,男性:33人\n",
|
|
"40~44岁平均成绩:2.94分,人数:21人,男性:17人\n",
|
|
"45~49岁平均成绩:2.89分,人数:33人,男性:25人\n",
|
|
"50~54岁平均成绩:3.1分,人数:17人,男性:16人\n",
|
|
"55~69岁平均成绩:2.85分,人数:7人,男性:7人\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nld = [[16,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]\n",
|
|
"\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for item in nld:\n",
|
|
" di = item[0]\n",
|
|
" gao = item[1]\n",
|
|
" i = 0\n",
|
|
" score = 0\n",
|
|
" m = 0\n",
|
|
" f = 0\n",
|
|
" for k,v in dict1.items():\n",
|
|
" if v['age'] in range(di,gao+1):\n",
|
|
" score = score+v['score']\n",
|
|
" i+=1\n",
|
|
" if v['sex'] == '男':\n",
|
|
" m = m +1\n",
|
|
" if i ==0:\n",
|
|
" print(f'{di}~{gao}岁平均成绩:0分,人数:0人,男性:{m}人')\n",
|
|
" else:\n",
|
|
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人,男性:{m}人')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "dafdffca-6543-4304-af61-4f7cd418ba24",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 根据年龄汇总人员信息及成绩(男)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"id": "347703a1-501b-4800-bd29-16e94f4a6793",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:35:34.912029Z",
|
|
"iopub.status.busy": "2024-12-20T07:35:34.911266Z",
|
|
"iopub.status.idle": "2024-12-20T07:35:34.922511Z",
|
|
"shell.execute_reply": "2024-12-20T07:35:34.921440Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:35:34.911960Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"20~24岁平均成绩:2.59分,人数:62人\n",
|
|
"25~29岁平均成绩:2.52分,人数:36人\n",
|
|
"30~34岁平均成绩:2.65分,人数:27人\n",
|
|
"35~39岁平均成绩:3.02分,人数:33人\n",
|
|
"40~44岁平均成绩:2.95分,人数:17人\n",
|
|
"45~49岁平均成绩:2.81分,人数:25人\n",
|
|
"50~54岁平均成绩:3.13分,人数:16人\n",
|
|
"55~80岁平均成绩:2.85分,人数:7人\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
|
|
"\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for item in nld:\n",
|
|
" di = item[0]\n",
|
|
" gao = item[1]\n",
|
|
" i = 0\n",
|
|
" score = 0\n",
|
|
" m = 0\n",
|
|
" f = 0\n",
|
|
" for k,v in dict1.items():\n",
|
|
" if v['age'] in range(di,gao+1) and v['sex'] == '男':\n",
|
|
" score = score+v['score']\n",
|
|
" i+=1\n",
|
|
" if i ==0:\n",
|
|
" print(f'{di}~{gao}岁平均成绩:0分,人数:{i}人') \n",
|
|
" else:\n",
|
|
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9b63891e-824a-4772-83f9-0706381ffd14",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 根据年龄汇总人员信息及成绩(女)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 29,
|
|
"id": "5900d1c7-2f8c-4dfa-a60e-a577fb90f22d",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-12T09:04:56.288764Z",
|
|
"iopub.status.busy": "2024-12-12T09:04:56.288050Z",
|
|
"iopub.status.idle": "2024-12-12T09:04:56.304610Z",
|
|
"shell.execute_reply": "2024-12-12T09:04:56.303440Z",
|
|
"shell.execute_reply.started": "2024-12-12T09:04:56.288700Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"20~24岁平均成绩:2.88分,人数:30人\n",
|
|
"25~29岁平均成绩:2.98分,人数:26人\n",
|
|
"30~34岁平均成绩:3.28分,人数:5人\n",
|
|
"35~39岁平均成绩:3.24分,人数:4人\n",
|
|
"40~44岁平均成绩:2.88分,人数:4人\n",
|
|
"45~49岁平均成绩:3.14分,人数:8人\n",
|
|
"50~54岁平均成绩:2.67分,人数:1人\n",
|
|
"55~80岁平均成绩:0分,人数:0人\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
|
|
"\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for item in nld:\n",
|
|
" di = item[0]\n",
|
|
" gao = item[1]\n",
|
|
" i = 0\n",
|
|
" score = 0\n",
|
|
" m = 0\n",
|
|
" f = 0\n",
|
|
" for k,v in dict1.items():\n",
|
|
" if v['age'] in range(di,gao+1) and v['sex'] == '女':\n",
|
|
" score = score+v['score']\n",
|
|
" i+=1\n",
|
|
" if i ==0:\n",
|
|
" print(f'{di}~{gao}岁平均成绩:0分,人数:{i}人') \n",
|
|
" else:\n",
|
|
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ca546652-d275-46d3-9b9a-9cb1c3a09a78",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算各项目成绩"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"id": "ad69c45d-3f62-42df-894d-47424e759029",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-20T07:34:04.864554Z",
|
|
"iopub.status.busy": "2024-12-20T07:34:04.863864Z",
|
|
"iopub.status.idle": "2024-12-20T07:34:04.875213Z",
|
|
"shell.execute_reply": "2024-12-20T07:34:04.874207Z",
|
|
"shell.execute_reply.started": "2024-12-20T07:34:04.864491Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"BMI 3.65 279\n",
|
|
"肺活量 3.37 268\n",
|
|
"握力 1.77 284\n",
|
|
"坐位体前屈 2.78 249\n",
|
|
"纵跳 2.82 245\n",
|
|
"俯卧撑 2.31 145\n",
|
|
"一分钟仰卧起坐 2.98 56\n",
|
|
"单脚站立 2.59 205\n",
|
|
"选择反应时 2.83 270\n",
|
|
"台阶指数 2.88 213\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
|
"for item in items:\n",
|
|
" score = 0\n",
|
|
" n = 0\n",
|
|
" for k, v in dict1.items(): \n",
|
|
" if item in v['fits'].keys():\n",
|
|
" n = n + 1\n",
|
|
" score =score + int(v['fits'][item]['score'])\n",
|
|
" print(item,round(score/n,2),n)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "f005328b-1927-4f62-b530-e7750299c423",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 按照部门计算平均成绩"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "dcf152e7-bbcc-47d1-9c5f-83854db35412",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"depart = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if v['unit'] not in depart:\n",
|
|
" depart.append(v['unit'])\n",
|
|
"\n",
|
|
"for item in depart:\n",
|
|
" score = 0\n",
|
|
" n = 0\n",
|
|
" for k, v in dict1.items():\n",
|
|
" if item == v['unit']:\n",
|
|
" score = score + v['score']\n",
|
|
" n = n +1 \n",
|
|
" print(item,round(score/n,2),n)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "83ca1488-9b2d-493c-b540-904a5f0af114",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 按照部门计算平均成绩(女性)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "d1977ca9-bf12-4f09-ae7b-e8af9eaa82f2",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"depart = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if v['unit'] not in depart:\n",
|
|
" depart.append(v['unit'])\n",
|
|
"\n",
|
|
"for item in depart:\n",
|
|
" score = 0\n",
|
|
" n = 0\n",
|
|
" for k, v in dict1.items():\n",
|
|
" if item == v['unit'] and v['sex'] == '女':\n",
|
|
" score = score + v['score']\n",
|
|
" n = n +1 \n",
|
|
" if n>0:\n",
|
|
" print(item,round(score/n,2),n)\n",
|
|
" else:\n",
|
|
" print(item,0,n)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9f111ad0-dfbe-408e-8652-b8f31fc910cb",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算部门等级"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "d507c7f7-6a91-4695-b700-5e2f77e6dea3",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"items = ['优秀','良好','合格','不合格'] \n",
|
|
"\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"\n",
|
|
"dict3 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" unit = v['unit']\n",
|
|
" dict3.setdefault(unit,{})\n",
|
|
" for item in items:\n",
|
|
" dict3[unit].setdefault(item,0)\n",
|
|
"\n",
|
|
"for k, v in dict1.items():\n",
|
|
" unit = v['unit']\n",
|
|
" #dict3.setdefault(unit,{})\n",
|
|
" #for item in items:\n",
|
|
" #dict3[unit].setdefault(v['level'],0)\n",
|
|
" dict3[unit][v['level']] +=1\n",
|
|
"for k, v in dict3.items():\n",
|
|
" print(k,v['优秀'],v['良好'],v['合格'],v['不合格'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "6345e3dc-509c-4a6f-8a0a-5c972d6f5828",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算部门成绩"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "90bc66cd-9f01-410e-9abc-e6f15ada293f",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数'] \n",
|
|
"filename = 'data/data_北海炼化2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"filename = 'data/北海炼化人员2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict2 = json.load(fl)\n",
|
|
"dict3 = {}\n",
|
|
"\n",
|
|
"for k, v in dict1.items():\n",
|
|
" unit = v['unit']\n",
|
|
" dict3.setdefault(unit,{})\n",
|
|
" for item in items:\n",
|
|
" dict3[unit].setdefault(item,{})\n",
|
|
" dict3[unit][item].setdefault('score',0)\n",
|
|
" dict3[unit][item].setdefault('count',0)\n",
|
|
" for k1,v1 in v['fits'].items():\n",
|
|
" if k1 in items:\n",
|
|
" dict3[unit][k1]['score']+=v1['score']\n",
|
|
" dict3[unit][k1]['count']+=1\n",
|
|
"\n",
|
|
"for k, v in dict3.items():\n",
|
|
" print(k)\n",
|
|
" for k1, v1 in v.items():\n",
|
|
" print(k1,v1['score'],v1['count'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "bdb81e20-32ec-4e0e-b2ac-13dac2060068",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"# 问卷数据处理分析"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "1485fc89-4fc2-437d-a29e-b4a0aab12aa0",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 常用参数及自定义函数"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"questions = [\n",
|
|
" [1],\n",
|
|
" [-1, 2],\n",
|
|
" [-1, 2],\n",
|
|
" [-1, 8],\n",
|
|
" [-1, 3],\n",
|
|
" [1],\n",
|
|
" [-1],\n",
|
|
" [-1, 7],\n",
|
|
" [2],\n",
|
|
" [2],\n",
|
|
" [2],\n",
|
|
" [2, 3],\n",
|
|
" [2],\n",
|
|
" [2],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9]\n",
|
|
"]\n",
|
|
"\n",
|
|
"kinds = [\n",
|
|
" '平和',\n",
|
|
" '气虚',\n",
|
|
" '阳虚',\n",
|
|
" '阴虚',\n",
|
|
" '痰湿',\n",
|
|
" '湿热',\n",
|
|
" '血瘀',\n",
|
|
" '气郁',\n",
|
|
" '特禀'\n",
|
|
"]\n",
|
|
"\n",
|
|
"def tcm_calc(arr):\n",
|
|
" qa = [8, 8, 7, 8, 8, 6, 7, 7, 7]\n",
|
|
" # 成绩数组\n",
|
|
" s = [0] * 9\n",
|
|
" # 遍历五进制\n",
|
|
" for i in range(len(questions)):\n",
|
|
" m = arr[i] - 1\n",
|
|
" for v in questions[i]:\n",
|
|
" if v < 0:\n",
|
|
" s[-v - 1] += 4 - m\n",
|
|
" else:\n",
|
|
" s[v - 1] += m\n",
|
|
" return [int((v / qa[i]) * 25) for i, v in enumerate(s)]\n",
|
|
"\n",
|
|
"def tcm_kind(score):\n",
|
|
" kind = 0\n",
|
|
" near = False\n",
|
|
" max_kind = 0\n",
|
|
" max_score = 0\n",
|
|
" for i in range(1, 9):\n",
|
|
" if score[i] > max_score:\n",
|
|
" max_kind = i\n",
|
|
" max_score = score[i]\n",
|
|
" if score[0] >= 60 and max_score < 40:\n",
|
|
" if max_score >= 30:\n",
|
|
" near = True\n",
|
|
" kind = max_kind\n",
|
|
" else:\n",
|
|
" kind = max_kind\n",
|
|
" return {\n",
|
|
" \"kind\": kind,\n",
|
|
" \"near\": near\n",
|
|
" }\n",
|
|
"list2 = ['成就感','愉快心境','放松程度','压力应对','体力充沛','情感充沛度']\n",
|
|
"list3 = [[5,7],[7,4],[7,4],[7,4],[8,1],[6,1]] \n",
|
|
"list4 = ['颈椎','胸椎','腰椎','骶尾椎']\n",
|
|
"list5 = [[0,10,10],[10,17,7],[17,24,6],[24,26,2]]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "df2d18e2-d2e4-499e-876a-59d8550a8201",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算中医体质"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1acaf159-637e-4101-9881-f6bb79400136",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"filename = 'data/result_北海炼化2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"i = 1\n",
|
|
"list2 = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if 'tcm' in v.keys():\n",
|
|
" list1 = []\n",
|
|
" tcm =v['tcm']\n",
|
|
" for item in tcm:\n",
|
|
" list1.append(item)\n",
|
|
" score = tcm_calc(list1)\n",
|
|
"\n",
|
|
" result = tcm_kind(score)\n",
|
|
" kind = result['kind']\n",
|
|
" near = result['near']\n",
|
|
" #print(i,k,kinds[kind], near, score)\n",
|
|
" #i+=1\n",
|
|
" list3 = []\n",
|
|
" list3.append(k)\n",
|
|
" list3.append(kinds[kind])\n",
|
|
" list3.append(near)\n",
|
|
" for item in score:\n",
|
|
" list3.append(item)\n",
|
|
" list2.append(list3)\n",
|
|
"print(list2)\n",
|
|
"filename = 'data/北海炼化中医情况明细表2024.xlsx'\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"\n",
|
|
"for row in list2:\n",
|
|
" sheet.append(row)\n",
|
|
" \n",
|
|
"wb.save(filename)\n",
|
|
"print('ok') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "cfb5661f-fd37-4372-9d22-3708d61680f9",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算心理"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 50,
|
|
"id": "ad3078ac-ae53-4bb4-95bd-387631092bf1",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-12-06T14:12:43.778020Z",
|
|
"iopub.status.busy": "2024-12-06T14:12:43.777211Z",
|
|
"iopub.status.idle": "2024-12-06T14:12:43.913724Z",
|
|
"shell.execute_reply": "2024-12-06T14:12:43.913244Z",
|
|
"shell.execute_reply.started": "2024-12-06T14:12:43.777944Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"ok\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"list2 = ['成就感','愉快心境','放松程度','压力应对','体力充沛','情感充沛度']\n",
|
|
"list3 = [[5,7],[7,4],[7,4],[7,4],[8,1],[6,1]]\n",
|
|
"qb = [\n",
|
|
" 1, 1, 1, 1, 1,\n",
|
|
" 4, 3, 2, 3, 2, 4, 3,\n",
|
|
" 4, 3, 2, 4, 4, 2, 4,\n",
|
|
" 3, 2, 2, 4, 3, 3, 2,\n",
|
|
" 5, 5, 5, 5, 5, 5, 5, 5,\n",
|
|
" 6, 6, 6, 6, 6, 6\n",
|
|
" ]\n",
|
|
"filename = 'data/result_北海炼化2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"list4 = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if 'psy' in v.keys():\n",
|
|
" list5 = []\n",
|
|
" psy=v['psy']\n",
|
|
" for i in range(26,40):\n",
|
|
" new_valve = psy[i]-1\n",
|
|
" psy[i] = new_valve\n",
|
|
" dict3 = {}\n",
|
|
" \n",
|
|
" i = 0\n",
|
|
" for item in qb:\n",
|
|
" dict3.setdefault(item,0)\n",
|
|
" dict3[item] +=psy[i]\n",
|
|
" i+=1\n",
|
|
" #print(dict3)\n",
|
|
" list5.append(k)\n",
|
|
" 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",
|
|
"filename = 'data/北海炼化心理情况明细表2024.xlsx'\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"\n",
|
|
"for row in list4:\n",
|
|
" sheet.append(row)\n",
|
|
" \n",
|
|
"wb.save(filename)\n",
|
|
"print('ok') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "20ef0e26-0f7b-4ee8-8b52-005e2d5ad0d4",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算脊柱"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 63,
|
|
"id": "122f19fb-3531-4074-94e4-e2afdb8af51a",
|
|
"metadata": {
|
|
"execution": {
|
|
"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": [
|
|
{
|
|
"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",
|
|
" 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",
|
|
" 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": "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": "1fcca066-04a7-41c1-8c5e-aea251b87250",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|