This commit is contained in:
512song committed 2024-09-29 10:22:23 +08:00
1 parent 3a9cb48f1e
commit c03192efe5
4 files changed
+295 -113

No files matched your search

+159 -2
View File
@@ -1,5 +1,13 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "b6ce4321-f82a-4d9d-a110-44a23b95970b",
"metadata": {},
"source": [
"# 2023年体质检测"
]
},
{
"cell_type": "markdown",
"id": "28695364-38de-442e-818d-cfab45902763",
@@ -840,10 +848,159 @@
"print(data)"
]
},
{
"cell_type": "markdown",
"id": "d3649684-3eab-49ad-8b3d-ebb452289e51",
"metadata": {},
"source": [
"# 2024年体质检测"
]
},
{
"cell_type": "markdown",
"id": "a3f5f78e-6785-48e6-b2b6-b91b8d2aa4ca",
"metadata": {},
"source": [
"## 导入人员信息"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "096e2b97-b83c-46bb-a070-c816e47da331",
"metadata": {
"execution": {
"iopub.execute_input": "2024-09-26T08:13:44.536115Z",
"iopub.status.busy": "2024-09-26T08:13:44.535333Z",
"iopub.status.idle": "2024-09-26T08:13:44.828454Z",
"shell.execute_reply": "2024-09-26T08:13:44.827938Z",
"shell.execute_reply.started": "2024-09-26T08:13:44.536043Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/东营石油工程设计公司(2024).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, 1).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" if sheet.cell(n, 5).value is not None:\n",
" dict1['gh'] = sheet.cell(n, 7).value\n",
" #dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0] \n",
" if sheet.cell(n, 4).value is not None:\n",
" dict1['phone'] = str(sheet.cell(n,6).value)\n",
"\n",
"\n",
" person[code] = dict1\n",
"filename = 'data/东营工程设计院2024.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "926e4dc3-fe7a-4b8b-9330-5a9eebc8a766",
"metadata": {},
"source": [
"## 获取人员测试成绩(新格式)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "28afeee6-43c0-4e96-b3aa-dc09c6288425",
"metadata": {
"execution": {
"iopub.execute_input": "2024-09-26T08:18:32.261817Z",
"iopub.status.busy": "2024-09-26T08:18:32.261244Z",
"iopub.status.idle": "2024-09-26T08:18:32.276332Z",
"shell.execute_reply": "2024-09-26T08:18:32.275838Z",
"shell.execute_reply.started": "2024-09-26T08:18:32.261764Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"75\n",
"75\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/东营工程设计院2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20240926.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",
" 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]['unit'] = dict1[user]['unit']\n",
" #re_ta[user]['sub_unit'] = dict1[user]['sub_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_东营工程设计院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": "code",
"execution_count": null,
"id": "c5ef31b6-ceed-4167-bec7-58e92b3698e1",
"id": "cef2ced9-2cd1-4632-8fe6-6a5a57e2fcb3",
"metadata": {},
"outputs": [],
"source": []
@@ -865,7 +1022,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.3"
}
},
"nbformat": 4,