This commit is contained in:
512song committed 2023-04-15 13:16:52 +00:00
1 parent 3099922e08
commit 140873c0bb
2 files changed
+127 -198

No files matched your search

+119 -138
View File
@@ -104,6 +104,73 @@
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "6fc0bfbd-a5cd-4720-bc66-14d74d730fc7",
"metadata": {},
"source": [
"### 获取人员测试成绩(新格式)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4ffa6cd8-98a2-4975-af00-8647a0888bdd",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import time\n",
"import csv\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",
"\n",
"dict1 = {}\n",
"list1 = []\n",
"#print(\"\\n运动项目信息:\")\n",
"filename = 'data/141.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",
"list2 = []\n",
"re_ta = {}\n",
"for result in list1:\n",
" user = str(result[4])\n",
" m_item = str(result[0]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = str(result[6])\n",
" re_ta[user]['unit'] = str(result[5]) \n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[1])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
" re_ta[user][item_name]['得分'] =result[2]\n",
"for k, v in re_ta.items():\n",
" dict2 = {}\n",
" dict2['code'] = k\n",
" for k1, v1 in v.items():\n",
" dict2[k1] = v1\n",
" list2.append(dict2)\n",
"dict3 = {}\n",
"dict3['result'] = list2\n",
"filename = 'data/result_东营石油工程设计院(new).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict3, fl) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "c4107446-c0c6-4d76-9062-284ff806ec86",
@@ -536,31 +603,12 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"id": "aa32ab25-6cb7-4a1b-87f9-5ec2b11d9715",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-12T13:22:18.338825Z",
"iopub.status.busy": "2023-04-12T13:22:18.337969Z",
"iopub.status.idle": "2023-04-12T13:22:18.406570Z",
"shell.execute_reply": "2023-04-12T13:22:18.405537Z",
"shell.execute_reply.started": "2023-04-12T13:22:18.338784Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0~255分人数:58人,男性:54人,女性:4人\n",
"256~332分人数:149人,男性:96人,女性:53人\n",
"333~367分人数:95人,男性:43人,女性:52人\n",
"368~500分人数:34人,男性:10人,女性:24人\n",
"ok\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"\n",
@@ -606,35 +654,12 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"id": "1759fc30-f390-4ed1-8d48-5eacc050e18f",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-12T13:36:32.351702Z",
"iopub.status.busy": "2023-04-12T13:36:32.350823Z",
"iopub.status.idle": "2023-04-12T13:36:32.375360Z",
"shell.execute_reply": "2023-04-12T13:36:32.374336Z",
"shell.execute_reply.started": "2023-04-12T13:36:32.351659Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20-24 {'合格': 9, '良好': 3, '不合格': 6, '优秀': 0}\n",
"25-29 {'不合格': 12, '合格': 20, '优秀': 1, '良好': 5}\n",
"30-34 {'合格': 14, '良好': 8, '不合格': 11, '优秀': 1}\n",
"35-39 {'良好': 7, '优秀': 3, '合格': 16, '不合格': 8}\n",
"40-44 {'良好': 9, '合格': 11, '优秀': 1, '不合格': 4}\n",
"45-49 {'良好': 5, '优秀': 2, '合格': 6, '不合格': 3}\n",
"50-54 {'良好': 3, '合格': 14, '优秀': 2, '不合格': 3}\n",
"55-59 {'不合格': 7, '合格': 6, '优秀': 0, '良好': 2}\n",
"60-69 {'良好': 1}\n"
]
}
],
"outputs": [],
"source": [
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,59],[60,69]]\n",
"filename = 'data/result_东营设计院.json'\n",
@@ -674,35 +699,12 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": null,
"id": "b7b44be3-8cf1-48e6-a4a6-adfccdb8c0a9",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-12T13:38:24.872938Z",
"iopub.status.busy": "2023-04-12T13:38:24.872071Z",
"iopub.status.idle": "2023-04-12T13:38:24.900110Z",
"shell.execute_reply": "2023-04-12T13:38:24.899005Z",
"shell.execute_reply.started": "2023-04-12T13:38:24.872897Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20-24 {'合格': 3, '良好': 4, '不合格': 1, '优秀': 1}\n",
"25-29 {'不合格': 0, '合格': 6, '优秀': 2, '良好': 9}\n",
"30-34 {'合格': 15, '良好': 7, '不合格': 2, '优秀': 3}\n",
"35-39 {'良好': 13, '优秀': 6, '合格': 10, '不合格': 0}\n",
"40-44 {'良好': 10, '合格': 5, '优秀': 6, '不合格': 0}\n",
"45-49 {'良好': 4, '优秀': 3, '合格': 4, '不合格': 0}\n",
"50-54 {'良好': 3, '合格': 9, '优秀': 2, '不合格': 1}\n",
"55-59 {'不合格': 0, '合格': 1, '优秀': 1, '良好': 2}\n",
"60-69 {'良好': 0}\n"
]
}
],
"outputs": [],
"source": [
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,59],[60,69]]\n",
"filename = 'data/result_东营设计院.json'\n",
@@ -742,50 +744,12 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": null,
"id": "975bb98b-a00c-4a34-b9a3-fe9975c12641",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-12T13:51:18.537293Z",
"iopub.status.busy": "2023-04-12T13:51:18.536443Z",
"iopub.status.idle": "2023-04-12T13:51:18.557426Z",
"shell.execute_reply": "2023-04-12T13:51:18.556451Z",
"shell.execute_reply.started": "2023-04-12T13:51:18.537253Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"管道工程设计所 3.19 19\n",
"建筑设计所 3.03 15\n",
"机械设备所 3.31 24\n",
"油气工艺设计所 2.96 18\n",
"工程勘察公司 3.12 33\n",
"水处理及热力工程设计所 2.85 25\n",
"自控通信所 3.13 20\n",
"海洋工程设计所 3.04 26\n",
"电力设计所 3.07 19\n",
"智能化研究中心 3.04 28\n",
"HSE管理部 3.44 1\n",
"项目管理中心 3.1 17\n",
"节能环保工程技术中心 3.1 18\n",
"技术发展中心 2.7 10\n",
"工程监理公司 3.16 7\n",
"工程造价中心 2.94 9\n",
"档案管理中心 3.15 8\n",
"国际工程管理部 3.11 6\n",
"党群工作部 3.78 1\n",
"市场开发部 2.8 7\n",
"综合服务中心 2.96 12\n",
"技术质量部 3.67 2\n",
"财务资产部 2.93 9\n",
"综合管理部 2.94 2\n"
]
}
],
"outputs": [],
"source": [
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
@@ -815,36 +779,12 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": null,
"id": "f51baed5-8d03-4d33-8d68-37ac13f9a47d",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-12T13:59:23.343983Z",
"iopub.status.busy": "2023-04-12T13:59:23.343101Z",
"iopub.status.idle": "2023-04-12T13:59:23.365478Z",
"shell.execute_reply": "2023-04-12T13:59:23.364375Z",
"shell.execute_reply.started": "2023-04-12T13:59:23.343942Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"体重 3.53\n",
"肺活量 3.57\n",
"握力 2.15\n",
"坐位体前屈 2.64\n",
"纵跳 2.8\n",
"俯卧撑 3.19\n",
"一分钟仰卧起坐 4.27\n",
"单脚站立 2.94\n",
"选择反应时 3.75\n",
"台阶指数 2.56\n"
]
}
],
"outputs": [],
"source": [
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
@@ -859,10 +799,51 @@
" print(item,round(score/n,2))"
]
},
{
"cell_type": "markdown",
"id": "adb043d9-4e1f-49eb-b051-84e4efbc3c72",
"metadata": {},
"source": [
"### 使用JMESPath查询"
]
},
{
"cell_type": "code",
"execution_count": 70,
"id": "7b148f6d-0d6d-4573-9df3-ea02faab165d",
"metadata": {
"execution": {
"iopub.execute_input": "2023-04-15T12:32:09.317495Z",
"iopub.status.busy": "2023-04-15T12:32:09.316589Z",
"iopub.status.idle": "2023-04-15T12:32:09.333606Z",
"shell.execute_reply": "2023-04-15T12:32:09.332528Z",
"shell.execute_reply.started": "2023-04-15T12:32:09.317454Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[['张东红', '建筑设计所'], ['孙淑华', '建筑设计所'], ['靳永东', '建筑设计所'], ['张浩', '建筑设计所'], ['宁聪聪', '建筑设计所'], ['李磊', '建筑设计所'], ['尚华凯', '建筑设计所'], ['王修龙', '建筑设计所'], ['王剑', '建筑设计所'], ['李天萌', '建筑设计所'], ['崔华强', '建筑设计所'], ['王乙臻', '建筑设计所'], ['刘小燕', '建筑设计所'], ['韦盛', '建筑设计所'], ['张跃', '建筑设计所']]\n"
]
}
],
"source": [
"from jmespath import search\n",
"filename = 'data/result_东营石油工程设计院(new).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"unit = \"建筑设计所\"\n",
"data = search(\"result[?unit== '建筑设计所'].[name,unit]\",dict1)\n",
"print(data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1617ddd9-b744-48a3-a4d5-1166b16821cb",
"id": "c5ef31b6-ceed-4167-bec7-58e92b3698e1",
"metadata": {},
"outputs": [],
"source": []