From a08571544fabe948a596de64763945c8c0ee10ce Mon Sep 17 00:00:00 2001 From: 512song Date: Wed, 28 May 2025 15:21:57 +0800 Subject: [PATCH] 20250528 --- 体测单位/农工党延庆支部.ipynb | 2 +- 体测单位/喀什.ipynb | 54 +++--- 体测单位/国图.ipynb | 54 +++--- 体测单位/宁夏能化.ipynb | 315 ++++++++++++++++++++++++++++++++++ 4 files changed, 370 insertions(+), 55 deletions(-) create mode 100644 体测单位/宁夏能化.ipynb diff --git a/体测单位/农工党延庆支部.ipynb b/体测单位/农工党延庆支部.ipynb index 7654a08..038f072 100644 --- a/体测单位/农工党延庆支部.ipynb +++ b/体测单位/农工党延庆支部.ipynb @@ -808,7 +808,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.12.3" } }, "nbformat": 4, diff --git a/体测单位/喀什.ipynb b/体测单位/喀什.ipynb index e15a7f7..3cc6067 100644 --- a/体测单位/喀什.ipynb +++ b/体测单位/喀什.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 18, "id": "2f3742c3-0247-4304-a580-530102cad1dc", "metadata": { "execution": { - "iopub.execute_input": "2025-04-18T11:10:42.531720Z", - "iopub.status.busy": "2025-04-18T11:10:42.531045Z", - "iopub.status.idle": "2025-04-18T11:10:42.555488Z", - "shell.execute_reply": "2025-04-18T11:10:42.555024Z", - "shell.execute_reply.started": "2025-04-18T11:10:42.531659Z" + "iopub.execute_input": "2025-04-22T11:50:56.869795Z", + "iopub.status.busy": "2025-04-22T11:50:56.869051Z", + "iopub.status.idle": "2025-04-22T11:50:56.891836Z", + "shell.execute_reply": "2025-04-22T11:50:56.891253Z", + "shell.execute_reply.started": "2025-04-22T11:50:56.869726Z" } }, "outputs": [ @@ -74,15 +74,15 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 19, "id": "8b649b7e-2608-4954-91ce-66f15b7e7806", "metadata": { "execution": { - "iopub.execute_input": "2025-04-18T11:20:10.114652Z", - "iopub.status.busy": "2025-04-18T11:20:10.113955Z", - "iopub.status.idle": "2025-04-18T11:20:10.173445Z", - "shell.execute_reply": "2025-04-18T11:20:10.172818Z", - "shell.execute_reply.started": "2025-04-18T11:20:10.114567Z" + "iopub.execute_input": "2025-04-22T11:51:02.601227Z", + "iopub.status.busy": "2025-04-22T11:51:02.600489Z", + "iopub.status.idle": "2025-04-22T11:51:02.610977Z", + "shell.execute_reply": "2025-04-22T11:51:02.610263Z", + "shell.execute_reply.started": "2025-04-22T11:51:02.601160Z" } }, "outputs": [ @@ -90,7 +90,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "8\n" + "11\n" ] } ], @@ -104,7 +104,7 @@ "filename = 'data/喀什人员.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", - "filename = 'data/marks_20250418-17.csv'\n", + "filename = 'data/marks_20250422.csv'\n", "re_ta = My.get_result(filename,dict1)\n", "\n", "filename = 'data/result_喀什人员.json'\n", @@ -123,15 +123,15 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 20, "id": "fa481310-fb25-4523-9558-eef6717452ba", "metadata": { "execution": { - "iopub.execute_input": "2025-04-18T11:20:25.827544Z", - "iopub.status.busy": "2025-04-18T11:20:25.826774Z", - "iopub.status.idle": "2025-04-18T11:20:25.836011Z", - "shell.execute_reply": "2025-04-18T11:20:25.835054Z", - "shell.execute_reply.started": "2025-04-18T11:20:25.827472Z" + "iopub.execute_input": "2025-04-22T11:51:04.831016Z", + "iopub.status.busy": "2025-04-22T11:51:04.830415Z", + "iopub.status.idle": "2025-04-22T11:51:04.842945Z", + "shell.execute_reply": "2025-04-22T11:51:04.841682Z", + "shell.execute_reply.started": "2025-04-22T11:51:04.830959Z" } }, "outputs": [ @@ -189,15 +189,15 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 21, "id": "480fe004-aea6-4477-9fdd-a80818d731ac", "metadata": { "execution": { - "iopub.execute_input": "2025-04-18T11:22:33.834413Z", - "iopub.status.busy": "2025-04-18T11:22:33.833674Z", - "iopub.status.idle": "2025-04-18T11:22:38.694275Z", - "shell.execute_reply": "2025-04-18T11:22:38.693755Z", - "shell.execute_reply.started": "2025-04-18T11:22:33.834343Z" + "iopub.execute_input": "2025-04-22T11:51:06.864802Z", + "iopub.status.busy": "2025-04-22T11:51:06.864080Z", + "iopub.status.idle": "2025-04-22T11:51:13.370634Z", + "shell.execute_reply": "2025-04-22T11:51:13.369406Z", + "shell.execute_reply.started": "2025-04-22T11:51:06.864736Z" } }, "outputs": [ @@ -205,7 +205,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "8\n" + "11\n" ] } ], diff --git a/体测单位/国图.ipynb b/体测单位/国图.ipynb index 3539f87..e15fcb6 100644 --- a/体测单位/国图.ipynb +++ b/体测单位/国图.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 18, "id": "2f3742c3-0247-4304-a580-530102cad1dc", "metadata": { "execution": { - "iopub.execute_input": "2025-04-20T04:22:01.142045Z", - "iopub.status.busy": "2025-04-20T04:22:01.141435Z", - "iopub.status.idle": "2025-04-20T04:22:01.168907Z", - "shell.execute_reply": "2025-04-20T04:22:01.168091Z", - "shell.execute_reply.started": "2025-04-20T04:22:01.141989Z" + "iopub.execute_input": "2025-04-24T05:31:25.507735Z", + "iopub.status.busy": "2025-04-24T05:31:25.507412Z", + "iopub.status.idle": "2025-04-24T05:31:25.525701Z", + "shell.execute_reply": "2025-04-24T05:31:25.525213Z", + "shell.execute_reply.started": "2025-04-24T05:31:25.507708Z" } }, "outputs": [ @@ -76,15 +76,15 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 19, "id": "8b649b7e-2608-4954-91ce-66f15b7e7806", "metadata": { "execution": { - "iopub.execute_input": "2025-04-20T04:22:08.503287Z", - "iopub.status.busy": "2025-04-20T04:22:08.502559Z", - "iopub.status.idle": "2025-04-20T04:22:08.510531Z", - "shell.execute_reply": "2025-04-20T04:22:08.509473Z", - "shell.execute_reply.started": "2025-04-20T04:22:08.503221Z" + "iopub.execute_input": "2025-04-24T05:31:31.562545Z", + "iopub.status.busy": "2025-04-24T05:31:31.561874Z", + "iopub.status.idle": "2025-04-24T05:31:31.572577Z", + "shell.execute_reply": "2025-04-24T05:31:31.571499Z", + "shell.execute_reply.started": "2025-04-24T05:31:31.562490Z" } }, "outputs": [ @@ -92,7 +92,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "15\n" + "4\n" ] } ], @@ -106,7 +106,7 @@ "filename = 'data/国图人员.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", - "filename = 'data/marks_20250420.csv'\n", + "filename = 'data/marks_20250424.csv'\n", "re_ta = My.get_result(filename,dict1)\n", "\n", "filename = 'data/result_国图人员.json'\n", @@ -125,15 +125,15 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 20, "id": "fa481310-fb25-4523-9558-eef6717452ba", "metadata": { "execution": { - "iopub.execute_input": "2025-04-20T04:22:25.993177Z", - "iopub.status.busy": "2025-04-20T04:22:25.992466Z", - "iopub.status.idle": "2025-04-20T04:22:26.005267Z", - "shell.execute_reply": "2025-04-20T04:22:26.003739Z", - "shell.execute_reply.started": "2025-04-20T04:22:25.993111Z" + "iopub.execute_input": "2025-04-24T05:31:35.098100Z", + "iopub.status.busy": "2025-04-24T05:31:35.097683Z", + "iopub.status.idle": "2025-04-24T05:31:35.104461Z", + "shell.execute_reply": "2025-04-24T05:31:35.103969Z", + "shell.execute_reply.started": "2025-04-24T05:31:35.098077Z" } }, "outputs": [ @@ -191,15 +191,15 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 21, "id": "480fe004-aea6-4477-9fdd-a80818d731ac", "metadata": { "execution": { - "iopub.execute_input": "2025-04-20T04:22:29.739586Z", - "iopub.status.busy": "2025-04-20T04:22:29.739161Z", - "iopub.status.idle": "2025-04-20T04:22:37.051880Z", - "shell.execute_reply": "2025-04-20T04:22:37.051216Z", - "shell.execute_reply.started": "2025-04-20T04:22:29.739548Z" + "iopub.execute_input": "2025-04-24T05:31:37.488914Z", + "iopub.status.busy": "2025-04-24T05:31:37.488126Z", + "iopub.status.idle": "2025-04-24T05:31:39.680755Z", + "shell.execute_reply": "2025-04-24T05:31:39.680234Z", + "shell.execute_reply.started": "2025-04-24T05:31:37.488842Z" } }, "outputs": [ @@ -207,7 +207,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "15\n" + "4\n" ] } ], diff --git a/体测单位/宁夏能化.ipynb b/体测单位/宁夏能化.ipynb new file mode 100644 index 0000000..6caf399 --- /dev/null +++ b/体测单位/宁夏能化.ipynb @@ -0,0 +1,315 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "04524c85-988e-4dbf-86eb-939a9db7aa28", + "metadata": {}, + "source": [ + "## 体测人员导入" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "bbba6efc-73cd-4db6-bae7-014724fee731", + "metadata": { + "execution": { + "iopub.execute_input": "2025-05-28T06:35:11.550938Z", + "iopub.status.busy": "2025-05-28T06:35:11.550116Z", + "iopub.status.idle": "2025-05-28T06:35:11.969766Z", + "shell.execute_reply": "2025-05-28T06:35:11.969225Z", + "shell.execute_reply.started": "2025-05-28T06:35:11.550860Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "\n", + "wb = openpyxl.load_workbook('data/宁夏能化人员.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "person = {}\n", + "\n", + "for n in range(2, sheet.max_row+1):\n", + " code = int(sheet.cell(n, 2).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, 6).value\n", + " dict1['birth'] = sheet.cell(n,5).value\n", + " person[code] = dict1\n", + "filename = 'data/宁夏能化人员.json'\n", + "with open(filename, 'w') as fl:\n", + " json.dump(person, fl, ensure_ascii=False)\n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "048a95aa-1691-45f6-b933-6eaf95ae1d30", + "metadata": {}, + "source": [ + "## 生成读卡系统文件" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "ce406710-6b7d-4c51-98ec-78883bd3ce5f", + "metadata": { + "execution": { + "iopub.execute_input": "2025-05-28T06:36:24.201183Z", + "iopub.status.busy": "2025-05-28T06:36:24.200236Z", + "iopub.status.idle": "2025-05-28T06:36:24.222064Z", + "shell.execute_reply": "2025-05-28T06:36:24.221561Z", + "shell.execute_reply.started": "2025-05-28T06:36:24.201103Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "filename = 'data/宁夏能化人员.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", + " #if dict1['sex'] =='男':\n", + " # sex = 1\n", + " \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/data_宁夏能化人员.json\", \"w\",encoding = 'utf-8') as file:\n", + " file.write(json_data) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f", + "metadata": {}, + "source": [ + "## 获取人员测试成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "970e171e-1360-448f-a28c-520ccb8f314a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-11-26T12:31:39.094899Z", + "iopub.status.busy": "2023-11-26T12:31:39.094370Z", + "iopub.status.idle": "2023-11-26T12:31:39.114981Z", + "shell.execute_reply": "2023-11-26T12:31:39.114071Z", + "shell.execute_reply.started": "2023-11-26T12:31:39.094860Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "16\n", + "16\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/北京党校.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "filename = 'data/places_result_20231126.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", + " 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_北京党校20231126.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": "markdown", + "id": "d034a61d-1fbd-417b-99bd-277e43ebb678", + "metadata": {}, + "source": [ + "## 导出测试人员信息" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "\n", + "filename = 'data/result_北京党校.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "\n", + "filename = 'data/北京党校.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", + " 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": "699c6a40-a6ae-4300-9646-708cb85aa5e8", + "metadata": {}, + "source": [ + "## 手工数据导入数据库" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "def3f47a-24ef-4815-b63b-2a16b79b4c15", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "filename = 'data/北京党校.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", + "wb = openpyxl.load_workbook('data/北京党校手工数据.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "dict1 = {}\n", + "dict3 = {1:10,2:11,3:7,4:2,5:6,6:3,7:1}\n", + "sheet = wb.active\n", + "data1 =list(sheet.values)\n", + "del data1[0]\n", + "list1 = []\n", + "for item in data1:\n", + " code = int(item[0])\n", + " list1.append((496534,code,item[2],item[1],'2023-10-15','2023-10-15 14:00:00'))\n", + "print(list1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "67e63f07-3f20-4e0e-9c07-7bf6024eeb4b", + "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.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}