This commit is contained in:
512song committed 2024-11-22 15:50:59 +08:00
1 parent aede8ad173
commit ac36b00339
5 files changed
+297 -152

No files matched your search

+224 -23
View File
@@ -1744,12 +1744,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "f0608de5-07ae-458c-999e-60968314f058",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-18T07:24:22.978299Z",
"iopub.status.busy": "2024-11-18T07:24:22.977549Z",
"iopub.status.idle": "2024-11-18T07:24:23.255535Z",
"shell.execute_reply": "2024-11-18T07:24:23.254995Z",
"shell.execute_reply.started": "2024-11-18T07:24:22.978234Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
@@ -1769,7 +1784,7 @@
" list2.append(dict1[k]['name']) \n",
" list2.append(dict1[k]['sex'])\n",
" list2.append(dict1[k]['unit'])\n",
" list2.append(dict1[k]['phone'])\n",
" #list2.append(dict1[k]['phone'])\n",
" i = 0\n",
" if 'bmi' in dict1[k].keys():\n",
" list2.append(dict1[k]['height']['成绩'])\n",
@@ -1980,20 +1995,14 @@
" i+=1"
]
},
{
"cell_type": "markdown",
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
"metadata": {},
"source": [
"# 2024年体质检测"
]
},
{
"cell_type": "markdown",
"id": "a51dadfb-30e7-40f3-a437-321aa986a10f",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 北海体检情况汇总"
"# 北海体检情况汇总"
]
},
{
@@ -2061,16 +2070,9 @@
},
{
"cell_type": "code",
"execution_count": 158,
"execution_count": null,
"id": "28825d80-9123-4ec5-b107-9ad133f11a82",
"metadata": {
"execution": {
"iopub.execute_input": "2024-04-11T03:17:59.468194Z",
"iopub.status.busy": "2024-04-11T03:17:59.467979Z",
"iopub.status.idle": "2024-04-11T03:17:59.981566Z",
"shell.execute_reply": "2024-04-11T03:17:59.981079Z",
"shell.execute_reply.started": "2024-04-11T03:17:59.468179Z"
},
"tags": []
},
"outputs": [],
@@ -2102,10 +2104,209 @@
"wb.save(filename) "
]
},
{
"cell_type": "markdown",
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
"metadata": {},
"source": [
"# 2024年体质检测"
]
},
{
"cell_type": "markdown",
"id": "b638855a-6540-44af-8f1c-796535a02a50",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c9262823-f492-4934-a0ce-f8f80c4a1bea",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-21T06:38:27.978576Z",
"iopub.status.busy": "2024-11-21T06:38:27.977760Z",
"iopub.status.idle": "2024-11-21T06:38:28.260893Z",
"shell.execute_reply": "2024-11-21T06:38:28.260411Z",
"shell.execute_reply.started": "2024-11-21T06:38:27.978502Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/北海人员202410.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(3, sheet.max_row+1):\n",
" code = int(sheet.cell(n, 1).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 2).value\n",
" dict1['sex'] = sheet.cell(n, 3).value\n",
" dict1['unit'] = sheet.cell(n, 6).value\n",
" dict1['phone'] = sheet.cell(n, 5).value\n",
" dict1['birth'] = sheet.cell(n,4).value\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": "bf58deff-7f90-4828-976d-a78858326853",
"metadata": {},
"source": [
"## 生成读卡系统文件"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "ffd34b08-40fd-45c5-a2d3-33c460c7b1dd",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-15T08:58:30.529702Z",
"iopub.status.busy": "2024-11-15T08:58:30.528869Z",
"iopub.status.idle": "2024-11-15T08:58:30.546247Z",
"shell.execute_reply": "2024-11-15T08:58:30.545156Z",
"shell.execute_reply.started": "2024-11-15T08:58:30.529616Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/北海炼化人员2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" dict2 = {}\n",
" dict2 = {'id':k,'name':v['name'],'gender':v['sex'],'birth':v['birth'],'unit':v['unit']}\n",
" list1.append(dict2)\n",
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
"\n",
"# 将 json 数据写入文件\n",
"with open(\"data/card_北海炼化人员2024.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "33633f3a-e2ff-4703-850f-a5b82c0a6280",
"metadata": {},
"source": [
"## 获取人员测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "202dcc9d-1f36-43c4-ad8d-8ee8c9db90ce",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-21T07:01:27.546392Z",
"iopub.status.busy": "2024-11-21T07:01:27.545774Z",
"iopub.status.idle": "2024-11-21T07:01:27.560036Z",
"shell.execute_reply": "2024-11-21T07:01:27.559152Z",
"shell.execute_reply.started": "2024-11-21T07:01:27.546333Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6\n",
"6\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/marks_20241121.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",
" item_name = 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]['rq'] = result[5].replace('/','-')\n",
" #re_ta[user]['sub_unit'] = dict1[user]['sub_unit'] \n",
" re_ta[user].setdefault(item_name,{})\n",
" #if item_name =='bmi':\n",
" # height = result[4].split(',')[0]\n",
" # weight = result[4].split(',')[1]\n",
" # re_ta[user]['height']['成绩'] = height\n",
" # re_ta[user]['weight']['成绩'] = weight\n",
" # re_ta[user]['bmi']['成绩'] = result[4]\n",
" #else:\n",
" # re_ta[user][item_name]['成绩'] = result[4]\n",
" re_ta[user][item_name]['成绩'] = result[4]\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": "d3e0075b-7a93-4454-860b-ba523e63ea08",
"id": "7e5d9787-e982-4afd-8d48-83766f5ed1d0",
"metadata": {},
"outputs": [],
"source": []
@@ -2127,7 +2328,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.3"
}
},
"nbformat": 4,