20230424
This commit is contained in:
1 parent
db04db8a17
commit
95bf9fd7dc
2 files changed
+456
-35
No files matched your search
@@ -0,0 +1,421 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "021f4ec4-47cd-433a-9d0a-91176b398f32",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导入人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "9bd78072-29e5-4c98-8bbe-97f525cf9e4a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-21T09:29:30.178602Z",
|
||||
"iopub.status.busy": "2023-04-21T09:29:30.177717Z",
|
||||
"iopub.status.idle": "2023-04-21T09:29:30.928850Z",
|
||||
"shell.execute_reply": "2023-04-21T09:29:30.927826Z",
|
||||
"shell.execute_reply.started": "2023-04-21T09:29:30.178561Z"
|
||||
},
|
||||
"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",
|
||||
"\n",
|
||||
"\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": 19,
|
||||
"id": "dd3c65ea-cc8a-4f1b-8698-d1799f99e101",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-24T09:55:49.171204Z",
|
||||
"iopub.status.busy": "2023-04-24T09:55:49.170336Z",
|
||||
"iopub.status.idle": "2023-04-24T09:55:49.259229Z",
|
||||
"shell.execute_reply": "2023-04-24T09:55:49.258337Z",
|
||||
"shell.execute_reply.started": "2023-04-24T09:55:49.171161Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"478\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_20230424-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_石家庄(20230424).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": 20,
|
||||
"id": "97d86ce2-6664-41a1-89d2-ddaa0611bac1",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-24T09:56:59.802126Z",
|
||||
"iopub.status.busy": "2023-04-24T09:56:59.801454Z",
|
||||
"iopub.status.idle": "2023-04-24T09:57:00.013623Z",
|
||||
"shell.execute_reply": "2023-04-24T09:57:00.012990Z",
|
||||
"shell.execute_reply.started": "2023-04-24T09:56:59.802093Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"filename = 'data/result_石家庄(20230424).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/石家庄石化体测情况表(20230424).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": 16,
|
||||
"id": "e2b68cb1-3a6f-4b51-afbd-d6c9634348b1",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-24T09:40:17.019067Z",
|
||||
"iopub.status.busy": "2023-04-24T09:40:17.018180Z",
|
||||
"iopub.status.idle": "2023-04-24T09:40:17.154594Z",
|
||||
"shell.execute_reply": "2023-04-24T09:40:17.153693Z",
|
||||
"shell.execute_reply.started": "2023-04-24T09:40:17.019024Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1200\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_20230424-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_石家庄.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e5de157c-18e2-4a6a-bae8-3db88822b88f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计部门测试情况"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"id": "57b22a08-554b-4b23-b98c-002b4608729f",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-24T09:40:43.681959Z",
|
||||
"iopub.status.busy": "2023-04-24T09:40:43.681329Z",
|
||||
"iopub.status.idle": "2023-04-24T09:40:43.726717Z",
|
||||
"shell.execute_reply": "2023-04-24T09:40:43.725677Z",
|
||||
"shell.execute_reply.started": "2023-04-24T09:40:43.681925Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'综合办公室(党委办公室)': 16, '销运管理部': 36, '企业管理部(法律事务部)': 12, '合资运行部': 22, '消防支队': 30, '设备工程部': 43, '党群文化部(宣传工团)': 9, '检验计量中心': 107, '发展计划部计划组': 8, '物资采购中心': 31, '炼油运行一部': 61, '审计管理部': 6, '发展计划部发展规划组': 11, '财务管理部': 16, '生产技术部': 26, '党委组织部(资源管理部)': 7, '安全环保部': 20, '储运运行部': 95, '化工运行部': 126, '信息中心': 14, '热电运行部': 48, '炼油运行三部': 52, '行政事务中心': 24, '电气仪表中心': 76, '炼油运行五部': 59, '水务运行部': 82, '编组站': 22, '炼油运行二部': 52, '炼油运行四部': 87, '纪委(监督部)': 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/石家庄测试名单部门情况(20230424).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": 18,
|
||||
"id": "0001a577-3d89-4e3d-be07-51cc74e3640f",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-24T09:41:20.642552Z",
|
||||
"iopub.status.busy": "2023-04-24T09:41:20.641713Z",
|
||||
"iopub.status.idle": "2023-04-24T09:41:20.758674Z",
|
||||
"shell.execute_reply": "2023-04-24T09:41:20.757988Z",
|
||||
"shell.execute_reply.started": "2023-04-24T09:41:20.642510Z"
|
||||
},
|
||||
"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/石家庄未测试名单(截至20230424).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
|
||||
}
|
||||
Reference in new issue
Block a user