484 lines
15 KiB
Plaintext
484 lines
15 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "021f4ec4-47cd-433a-9d0a-91176b398f32",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导入人员信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 29,
|
||
"id": "9bd78072-29e5-4c98-8bbe-97f525cf9e4a",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-26T09:21:52.196489Z",
|
||
"iopub.status.busy": "2023-04-26T09:21:52.195668Z",
|
||
"iopub.status.idle": "2023-04-26T09:21:52.973388Z",
|
||
"shell.execute_reply": "2023-04-26T09:21:52.972674Z",
|
||
"shell.execute_reply.started": "2023-04-26T09:21:52.196448Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"ok\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/student_20140922(石家庄监测花名册2023年).xlsx')\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"person = {}\n",
|
||
"\n",
|
||
"for n in range(2, sheet.max_row+1):\n",
|
||
" if sheet.cell(n,1).value is not None:\n",
|
||
" code = int(sheet.cell(n, 4).value)\n",
|
||
" person.setdefault(code, {})\n",
|
||
" dict1 = {}\n",
|
||
" dict1['name'] = sheet.cell(n, 6).value\n",
|
||
" if sheet.cell(n, 7).value ==1:\n",
|
||
" sex = '男'\n",
|
||
" else:\n",
|
||
" sex = '女'\n",
|
||
" dict1['sex'] = sex\n",
|
||
" dict1['unit'] = sheet.cell(n, 3).value\n",
|
||
" person[code] = dict1\n",
|
||
"filename = 'data/石家庄2023.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "cb4e0b2a-a17a-470c-afcd-2a532c00f6d0",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 每日成绩导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 36,
|
||
"id": "dd3c65ea-cc8a-4f1b-8698-d1799f99e101",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-27T07:07:34.179338Z",
|
||
"iopub.status.busy": "2023-04-27T07:07:34.178517Z",
|
||
"iopub.status.idle": "2023-04-27T07:07:34.222956Z",
|
||
"shell.execute_reply": "2023-04-27T07:07:34.221926Z",
|
||
"shell.execute_reply.started": "2023-04-27T07:07:34.179297Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"118\n",
|
||
"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",
|
||
"re_ta = {}\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/石家庄2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"\n",
|
||
"filename = 'data/places_result_20230427-sjz.csv'\n",
|
||
"with open(filename,'r',newline='') as csv_file:\n",
|
||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||
" header = next(fl) \n",
|
||
" for line in fl:\n",
|
||
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||
" list1.append(line)\n",
|
||
"#print(list1)\n",
|
||
"for result in list1:\n",
|
||
" user = str(result[2])\n",
|
||
" if user in dict1.keys():\n",
|
||
" \n",
|
||
" m_item = str(result[3]) \n",
|
||
" re_ta.setdefault(user,{}) \n",
|
||
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
||
" re_ta[user]['部门'] = dict1[user]['unit']\n",
|
||
" item_name = item[m_item]['name']\n",
|
||
" re_ta[user].setdefault(item_name,{}) \n",
|
||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||
"print(len(re_ta))\n",
|
||
"filename = 'data/result_石家庄(20230427).json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(re_ta, fl) \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "a2127ef7-230f-434e-a817-3d4948ed0ca4",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 每日成绩导出"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 37,
|
||
"id": "97d86ce2-6664-41a1-89d2-ddaa0611bac1",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-27T07:07:54.855417Z",
|
||
"iopub.status.busy": "2023-04-27T07:07:54.854561Z",
|
||
"iopub.status.idle": "2023-04-27T07:07:54.933949Z",
|
||
"shell.execute_reply": "2023-04-27T07:07:54.932922Z",
|
||
"shell.execute_reply.started": "2023-04-27T07:07:54.855376Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"filename = 'data/result_石家庄(20230427).json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/石家庄2023.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(5,'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/石家庄石化体测情况表(20230427).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": "6fae0c4a-f0f6-4abe-bd3a-ea9fef87f2c6",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 总成绩导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 38,
|
||
"id": "e2b68cb1-3a6f-4b51-afbd-d6c9634348b1",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-27T07:10:23.308568Z",
|
||
"iopub.status.busy": "2023-04-27T07:10:23.307717Z",
|
||
"iopub.status.idle": "2023-04-27T07:10:23.593399Z",
|
||
"shell.execute_reply": "2023-04-27T07:10:23.592690Z",
|
||
"shell.execute_reply.started": "2023-04-27T07:10:23.308525Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"2254\n",
|
||
"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",
|
||
"re_ta = {}\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/石家庄2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"\n",
|
||
"filename = 'data/places_result_20230427-sjz-all.csv'\n",
|
||
"with open(filename,'r',newline='') as csv_file:\n",
|
||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||
" header = next(fl) \n",
|
||
" for line in fl:\n",
|
||
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||
" list1.append(line)\n",
|
||
"#print(list1)\n",
|
||
"for result in list1:\n",
|
||
" user = str(result[2])\n",
|
||
" if user in dict1.keys():\n",
|
||
" \n",
|
||
" m_item = str(result[3]) \n",
|
||
" re_ta.setdefault(user,{}) \n",
|
||
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
||
" re_ta[user]['部门'] = dict1[user]['unit']\n",
|
||
" item_name = item[m_item]['name']\n",
|
||
" re_ta[user].setdefault(item_name,{}) \n",
|
||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||
"print(len(re_ta))\n",
|
||
"filename = 'data/result_石家庄.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(re_ta, fl) \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "6adeedfe-999a-47c2-aeed-fb4467b27026",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 39,
|
||
"id": "29ed0a03-72e1-4bee-8d00-95555f129d93",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-27T07:11:19.132911Z",
|
||
"iopub.status.busy": "2023-04-27T07:11:19.132425Z",
|
||
"iopub.status.idle": "2023-04-27T07:11:19.660183Z",
|
||
"shell.execute_reply": "2023-04-27T07:11:19.659444Z",
|
||
"shell.execute_reply.started": "2023-04-27T07:11:19.132880Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"filename = 'data/result_石家庄.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/石家庄2023.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(5,'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/石家庄石化体测情况表.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": "e5de157c-18e2-4a6a-bae8-3db88822b88f",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计部门测试情况"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 35,
|
||
"id": "57b22a08-554b-4b23-b98c-002b4608729f",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-26T09:42:34.825177Z",
|
||
"iopub.status.busy": "2023-04-26T09:42:34.824747Z",
|
||
"iopub.status.idle": "2023-04-26T09:42:34.875587Z",
|
||
"shell.execute_reply": "2023-04-26T09:42:34.874720Z",
|
||
"shell.execute_reply.started": "2023-04-26T09:42:34.825140Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"{'综合办公室(党委办公室)': 19, '销运管理部': 41, '企业管理部(法律事务部)': 12, '合资运行部': 27, '消防支队': 39, '设备工程部': 44, '党群文化部(宣传工团)': 9, '检验计量中心': 180, '发展计划部计划组': 11, '物资采购中心': 52, '炼油运行一部': 112, '审计管理部': 6, '发展计划部发展规划组': 12, '财务管理部': 18, '生产技术部': 35, '党委组织部(资源管理部)': 16, '安全环保部': 26, '储运运行部': 151, '化工运行部': 267, '信息中心': 18, '热电运行部': 92, '炼油运行三部': 127, '行政事务中心': 45, '电气仪表中心': 196, '炼油运行五部': 120, '水务运行部': 133, '编组站': 49, '炼油运行二部': 113, '炼油运行四部': 168, '纪委(监督部)': 2}\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/result_石家庄.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['部门']\n",
|
||
" dict2.setdefault(unit,0)\n",
|
||
" dict2[unit] = dict2[unit] + 1\n",
|
||
"print(dict2)\n",
|
||
"title =['单位','体测人数']\n",
|
||
"list1 = [] \n",
|
||
"for k, v in dict2.items():\n",
|
||
" list2 = []\n",
|
||
" list2 = [k,v]\n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/石家庄测试名单部门情况(20230426).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": "187fc3c8-46f6-4d32-9b52-38efbf2403b4",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计未测试人员名单"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 34,
|
||
"id": "0001a577-3d89-4e3d-be07-51cc74e3640f",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-26T09:39:12.083561Z",
|
||
"iopub.status.busy": "2023-04-26T09:39:12.083234Z",
|
||
"iopub.status.idle": "2023-04-26T09:39:12.148788Z",
|
||
"shell.execute_reply": "2023-04-26T09:39:12.147956Z",
|
||
"shell.execute_reply.started": "2023-04-26T09:39:12.083534Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/result_石家庄.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/石家庄2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"for k, v in dict2.items():\n",
|
||
" if k not in dict1.keys():\n",
|
||
" list1.append([k,v['name'],v['unit']])\n",
|
||
"filename = 'data/石家庄未测试名单(截至20230426).xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"title =['测试编号','姓名','单位']\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
"wb.save(filename)\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "2c4b4bfc-6112-4e39-9188-32934479952b",
|
||
"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.10.6"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 5
|
||
}
|