This commit is contained in:
512song@sina.com committed 2022-10-26 23:44:08 +08:00
1 parent e8ceb486f9
commit 8b46588049
2 files changed
+458 -23

No files matched your search

+435
View File
@@ -0,0 +1,435 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "61f4a6eb-797e-4fe2-95df-e27b316c95f1",
"metadata": {},
"source": [
"### 人员基本信息导入"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "f6bc68b5-9ed8-4b28-ab1a-452107b6429a",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-26T11:58:59.214911Z",
"iopub.status.busy": "2022-10-26T11:58:59.214385Z",
"iopub.status.idle": "2022-10-26T11:59:00.200796Z",
"shell.execute_reply": "2022-10-26T11:59:00.199708Z",
"shell.execute_reply.started": "2022-10-26T11:58:59.214863Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"wb = openpyxl.load_workbook('data/北海石化监测花名册2022 .xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,2).value is None:\n",
" break\n",
" else: \n",
" code = int(sheet.cell(n, 4).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 6).value \n",
" xb = str(sheet.cell(n, 7).value)\n",
" if xb == '1':\n",
" sex = '男'\n",
" elif xb =='2':\n",
" sex = '女'\n",
" dict1['sex'] = sex\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" dict1['birth'] = str(sheet.cell(n,8).value).split(' ')[0]\n",
" person[code] = dict1\n",
"filename = 'data/北海炼化人员_2022.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "fe54b0b2-0abd-4ee9-827d-0e3a4c9bd1f2",
"metadata": {},
"source": [
"### 获取人员测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "97031317-76ed-4404-b922-6ca749e4fd2a",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-26T15:13:05.551848Z",
"iopub.status.busy": "2022-10-26T15:13:05.551291Z",
"iopub.status.idle": "2022-10-26T15:13:05.733924Z",
"shell.execute_reply": "2022-10-26T15:13:05.732766Z",
"shell.execute_reply.started": "2022-10-26T15:13:05.551800Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"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",
"#SQL语句为:\n",
"# SELECT a.item_id,a.performance,a.score,a.date AS DATE1,a.avatar_id,b.unit,b.name FROM places_result AS a,_zgshhgxs AS b WHERE a.place_id=135 AND a.avatar_id=b.id AND a.avatar_id < 4999\n",
"\n",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"#print(\"\\n运动项目信息:\")\n",
"filename = 'data/138_2210.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n",
"#print(list1)\n",
"for result in list1:\n",
" user = str(result[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",
"filename = 'data/result_北海炼化2022.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "be6b6709-a2b0-4c34-aca1-000e1fb45953",
"metadata": {},
"source": [
"### 导出测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "f70a02f2-934e-43ed-93ff-b34cb732dfc6",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-26T15:13:15.553588Z",
"iopub.status.busy": "2022-10-26T15:13:15.553050Z",
"iopub.status.idle": "2022-10-26T15:13:15.663507Z",
"shell.execute_reply": "2022-10-26T15:13:15.662380Z",
"shell.execute_reply.started": "2022-10-26T15:13:15.553540Z"
},
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位/部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"filename = 'data/result_北海炼化2022.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/北海炼化人员_2022.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
" \n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" list2 = []\n",
" list2.append(str(k).rjust(8,'0'))\n",
" list2.append(v['name']) \n",
" list2.append(dict2[k]['sex'])\n",
" list2.append(dict2[k]['unit']) \n",
" \n",
" for item in items:\n",
" if item in v.keys():\n",
" list2.append(v[item]['成绩']) \n",
" elif item =='name':\n",
" list2.append(v[item])\n",
" else:\n",
" list2.append('') \n",
" list1.append(list2)\n",
"filename = 'data/北海炼化体测情况表(截至20221026).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "5ec595eb-f979-425e-b7eb-9af094ffb43d",
"metadata": {},
"source": [
"### 导入2021年人员信息"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "a9460ee7-1f60-4a3b-a45d-8a1dba04b920",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-26T11:59:11.407159Z",
"iopub.status.busy": "2022-10-26T11:59:11.406624Z",
"iopub.status.idle": "2022-10-26T11:59:11.664219Z",
"shell.execute_reply": "2022-10-26T11:59:11.663061Z",
"shell.execute_reply.started": "2022-10-26T11:59:11.407111Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"filename = 'data/北海炼化人员_2022.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/all_result.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"dict3 = {}\n",
"dict3 = dict2['北海炼化']\n",
"\n",
"for k, v in dict1.items():\n",
" name = v['name']\n",
" birth = v['birth']\n",
" for k1, v1 in dict3.items():\n",
" if v1['name'] == name and v1['birth'] == birth:\n",
" dict1[k]['old_code'] = int(k1)\n",
" dict1[k]['record'] = v1['record']\n",
" \n",
"filename = 'data/北海炼化人员_2022.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "0a221ef2-0d86-45a7-916e-bce634a57bfe",
"metadata": {},
"source": [
"### 核对2021体测人员"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "61fbd157-f4f0-4c85-98dc-0e79ee99280b",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-26T11:59:14.395184Z",
"iopub.status.busy": "2022-10-26T11:59:14.394650Z",
"iopub.status.idle": "2022-10-26T11:59:14.567363Z",
"shell.execute_reply": "2022-10-26T11:59:14.566447Z",
"shell.execute_reply.started": "2022-10-26T11:59:14.395136Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"00068 张利雄 1987-09-24\n",
"00120 黎秀珍 1966-12-22\n",
"00259 彭秋丽 1989-08-15\n",
"00348 黄宏州 1995-02-19\n",
"00424 易华锋 1985-12-02\n",
"00524 周爱娟 1971-10-11\n",
"00525 马遥碧 1971-06-13\n",
"00534 潘永远 1962-03-24\n",
"00614 刘文涛 1997-07-13\n",
"00689 陈雪 1966-11-14\n",
"00725 冯剑秋 1972-01-07\n",
"00727 汪纯燕 1971-12-06\n",
"00733 曾媛 1972-07-14\n",
"00758 谭志坚 1972-04-02\n",
"00798 冯鸥 1992-11-24\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"filename = 'data/北海炼化人员_2022.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"list1 = []\n",
"for k,v in dict1.items():\n",
" if 'old_code' in v.keys():\n",
" list1.append(v['old_code'])\n",
"filename = 'data/all_result.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"dict3 = {}\n",
"dict3 = dict2['北海炼化']\n",
"for k, v in dict3.items():\n",
" if int(k) not in list1:\n",
" print(k,v['name'],v['birth'])"
]
},
{
"cell_type": "markdown",
"id": "e6698931-04fb-4dd8-a844-55790cbe3eb9",
"metadata": {},
"source": [
"### 比照人员两年成绩"
]
},
{
"cell_type": "markdown",
"id": "727be8d7-8a4c-4cf4-8139-476f407a31b0",
"metadata": {},
"source": [
"#### 比照两年单项成绩"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "d3ca4d45-6a83-4d50-8419-cf8aa9b3aa4c",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-26T12:11:23.788353Z",
"iopub.status.busy": "2022-10-26T12:11:23.787816Z",
"iopub.status.idle": "2022-10-26T12:11:23.836530Z",
"shell.execute_reply": "2022-10-26T12:11:23.835397Z",
"shell.execute_reply.started": "2022-10-26T12:11:23.788303Z"
},
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"filename = 'data/北海炼化人员_2022.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"list1 = dict1.keys()\n",
"items = ['台阶指数']\n",
"title = ['编号','姓名','部门','22年台阶指数','21年台阶指数']\n",
"filename = 'data/result_北海炼化2022.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"list4 = []\n",
"for k, v in dict2.items():\n",
" if k in list1:\n",
" list2 = [k,v['name'],v['unit']]\n",
" list3 = []\n",
" for item in items:\n",
" # 获取2022年成绩\n",
" if item in v.keys(): \n",
" list2.append(v[item]['成绩'].split()[0]) \n",
" else:\n",
" list2.append('')\n",
" # 获取2021年成绩\n",
" if 'record' in dict1[k].keys() and item in dict1[k]['record'].keys():\n",
" list3.append(dict1[k]['record'][item]['成绩']) \n",
" else:\n",
" list3.append('')\n",
" for cj in list3:\n",
" if cj != '':\n",
" list2.append(cj.split()[0]) \n",
" \n",
" list4.append(list2)\n",
"filename = 'data/b北海炼化成绩对照221026.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list4:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "70de1be8-e55c-4b7a-bad9-78ad77f199d0",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
+23 -23
View File
@@ -10,15 +10,15 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 30,
"id": "1144aaac-92a0-4bcf-aba7-096f7dd3ad3b",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-24T01:23:19.812476Z",
"iopub.status.busy": "2022-10-24T01:23:19.811935Z",
"iopub.status.idle": "2022-10-24T01:23:21.182395Z",
"shell.execute_reply": "2022-10-24T01:23:21.180972Z",
"shell.execute_reply.started": "2022-10-24T01:23:19.812426Z"
"iopub.execute_input": "2022-10-26T15:14:22.185120Z",
"iopub.status.busy": "2022-10-26T15:14:22.184598Z",
"iopub.status.idle": "2022-10-26T15:14:23.499268Z",
"shell.execute_reply": "2022-10-26T15:14:23.498134Z",
"shell.execute_reply.started": "2022-10-26T15:14:22.185071Z"
},
"tags": []
},
@@ -67,15 +67,15 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 26,
"id": "a57ebb22-543c-4804-8d44-89984058ec1d",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-24T01:21:48.803009Z",
"iopub.status.busy": "2022-10-24T01:21:48.802465Z",
"iopub.status.idle": "2022-10-24T01:21:48.864714Z",
"shell.execute_reply": "2022-10-24T01:21:48.863863Z",
"shell.execute_reply.started": "2022-10-24T01:21:48.802959Z"
"iopub.execute_input": "2022-10-26T15:13:30.118858Z",
"iopub.status.busy": "2022-10-26T15:13:30.118322Z",
"iopub.status.idle": "2022-10-26T15:13:30.350334Z",
"shell.execute_reply": "2022-10-26T15:13:30.349005Z",
"shell.execute_reply.started": "2022-10-26T15:13:30.118808Z"
},
"tags": []
},
@@ -107,7 +107,7 @@
"dict1 = {}\n",
"list1 = []\n",
"#print(\"\\n运动项目信息:\")\n",
"filename = 'data/134_221021.csv'\n",
"filename = 'data/134_2210.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -142,15 +142,15 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 31,
"id": "38397ad4-2bb3-4b5e-8ece-9ea11e801890",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-24T01:28:35.781995Z",
"iopub.status.busy": "2022-10-24T01:28:35.781432Z",
"iopub.status.idle": "2022-10-24T01:28:36.097993Z",
"shell.execute_reply": "2022-10-24T01:28:36.097009Z",
"shell.execute_reply.started": "2022-10-24T01:28:35.781947Z"
"iopub.execute_input": "2022-10-26T15:14:26.661745Z",
"iopub.status.busy": "2022-10-26T15:14:26.661218Z",
"iopub.status.idle": "2022-10-26T15:14:27.250915Z",
"shell.execute_reply": "2022-10-26T15:14:27.249692Z",
"shell.execute_reply.started": "2022-10-26T15:14:26.661696Z"
},
"tags": []
},
@@ -160,7 +160,7 @@
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位/部门','车间/科室','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
"title = ['编号','姓名','性别','单位/部门','车间/科室','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"filename = 'data/result_天津.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
@@ -181,14 +181,14 @@
" for item in items:\n",
" if item in v.keys():\n",
" list2.append(v[item]['成绩'])\n",
" list2.append(v[item]['得分'])\n",
" \n",
" elif item =='name':\n",
" list2.append(v[item])\n",
" else:\n",
" list2.append('') \n",
" list2.append('') \n",
" \n",
" list1.append(list2)\n",
"filename = 'data/天津石化得分情况表.xlsx'\n",
"filename = 'data/天津石化体测情况表(截至20221026).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",