From f463c8d49a38ddaa5a754bc395ac5ad6e9654867 Mon Sep 17 00:00:00 2001 From: "512song@sina.com" Date: Fri, 12 Aug 2022 15:13:07 +0800 Subject: [PATCH] 20220812 --- .../中医体质管理-checkpoint.ipynb | 157 +++++++++++++++--- 体质检测管理.ipynb | 55 +----- 2 files changed, 145 insertions(+), 67 deletions(-) diff --git a/.ipynb_checkpoints/中医体质管理-checkpoint.ipynb b/.ipynb_checkpoints/中医体质管理-checkpoint.ipynb index 966a03e..c509300 100644 --- a/.ipynb_checkpoints/中医体质管理-checkpoint.ipynb +++ b/.ipynb_checkpoints/中医体质管理-checkpoint.ipynb @@ -26,32 +26,17 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "1f58bd08-d20b-4a76-a841-ac7e132a54b7", "metadata": { - "execution": { - "iopub.execute_input": "2022-08-05T05:39:03.670486Z", - "iopub.status.busy": "2022-08-05T05:39:03.669966Z", - "iopub.status.idle": "2022-08-05T05:39:03.705022Z", - "shell.execute_reply": "2022-08-05T05:39:03.703508Z", - "shell.execute_reply.started": "2022-08-05T05:39:03.670438Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ok\n" - ] - } - ], + "outputs": [], "source": [ "import re\n", "import json\n", "\n", - "file_name = 'data/132.txt'\n", + "file_name = 'data/130.txt'\n", "list1 =[]\n", "dict1 = {}\n", "with open(file_name,'r') as fl:\n", @@ -61,16 +46,148 @@ " list2 = l.split(',')\n", " if list2[0] != '' and list2[5] != '':\n", " dict1[list2[0]] = [list2[1],list2[2],list2[3],list2[4],list2[5]+list2[6]]\n", - "filename = 'data/132中医体质.json'\n", + "filename = 'data/130中医体质.json'\n", "with open(filename,'w') as fl:\n", " json.dump(dict1, fl) \n", "print('ok')" ] }, + { + "cell_type": "markdown", + "id": "a0f172a9-a0f3-4d53-90f0-39dda318c59b", + "metadata": {}, + "source": [ + "### 测试人员分类" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "400f6c4b-8a67-4872-a912-a0aad86e923c", + "id": "e83b31a6-4fae-40be-8159-fd509999c6d5", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "dict1 = {}\n", + "filename = 'data/交警支队完成情况.xlsx'\n", + "wb = openpyxl.load_workbook(filename)\n", + "sheet = wb.active\n", + "for n in range(2, sheet.max_row+1):\n", + " bh = sheet.cell(n, 1).value\n", + " xm = sheet.cell(n, 3).value\n", + " if sheet.cell(n,8).value is not None:\n", + " dict1.setdefault('1', [])\n", + " dict1['1'].append(bh) \n", + " elif sheet.cell(n,8).value is None and sheet.cell(n,6).value is not None:\n", + " dict1.setdefault('2', [])\n", + " dict1['2'].append(bh)\n", + " elif sheet.cell(n,8).value is None and sheet.cell(n,6).value is None and sheet.cell(n,7).value is not None:\n", + " dict1.setdefault('3', [])\n", + " dict1['3'].append(bh)\n", + "filename = 'data/交警支队完成人员分类.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "566b134f-03ac-4f79-994e-f4a512d9e5f1", + "metadata": {}, + "source": [ + "### 生成测试人员分类表" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "1d0c8452-c3ac-4901-83cf-cefdeebee956", + "metadata": { + "execution": { + "iopub.execute_input": "2022-08-12T01:54:03.835733Z", + "iopub.status.busy": "2022-08-12T01:54:03.835180Z", + "iopub.status.idle": "2022-08-12T01:54:04.266745Z", + "shell.execute_reply": "2022-08-12T01:54:04.265693Z", + "shell.execute_reply.started": "2022-08-12T01:54:03.835686Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import csv\n", + "import openpyxl\n", + "\n", + "dict1 = {}\n", + "filename = 'data/交警支队成绩.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", + " dict1[line[0]] = line\n", + "filename = 'data/交警支队分组.xlsx'\n", + "wb = openpyxl.load_workbook(filename)\n", + "\n", + "fl_name = 'data/交警支队完成人员分类.json'\n", + "with open(fl_name,'r') as fl:\n", + " m_xx = json.load(fl)\n", + "for k, v in m_xx.items():\n", + " if k == '1':\n", + " sheet = wb['参加中医体质人员']\n", + " i = 2\n", + " for item in v:\n", + " bh = str(item) \n", + " sheet[f'A{i}'] = dict1[bh][4]\n", + " sheet[f'B{i}'] = dict1[bh][1]\n", + " sheet[f'C{i}'] = dict1[bh][2]\n", + " sheet[f'D{i}'] = dict1[bh][3]\n", + " sheet[f'E{i}'] = dict1[bh][26]\n", + " sheet[f'F{i}'] = dict1[bh][27]\n", + " i+=1\n", + " elif k == '2':\n", + " sheet = wb['参加体测未参加中医体测']\n", + " i = 2\n", + " for item in v:\n", + " bh = str(item)\n", + " list1 = dict1[bh]\n", + " for n in range(26):\n", + " sheet.cell(column = n+1, row=i, value=list1[n])\n", + " i+=1\n", + " else:\n", + " sheet = wb['只参加心理未参加中医']\n", + " i = 2\n", + " for item in v:\n", + " bh = str(item)\n", + " sheet[f'A{i}'] = bh\n", + " sheet[f'B{i}'] = dict1[bh][4]\n", + " sheet[f'C{i}'] = dict1[bh][1]\n", + " sheet[f'D{i}'] = dict1[bh][2]\n", + " sheet[f'E{i}'] = dict1[bh][3]\n", + " list1 = dict1[bh]\n", + " for n in range(6,16):\n", + " sheet.cell(column = n, row=i, value=list1[31+n])\n", + " i+=1 \n", + " \n", + "wb.save('data/交警支队分组1.xlsx') " + ] + }, + { + "cell_type": "markdown", + "id": "56998dde-2263-46f1-b315-75be8488ece1", + "metadata": {}, + "source": [ + "### 人员手机号码核对" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c897d05b-6e6a-46f0-897f-7ec670aba0a0", "metadata": {}, "outputs": [], "source": [] diff --git a/体质检测管理.ipynb b/体质检测管理.ipynb index 0c75682..e137c5e 100644 --- a/体质检测管理.ipynb +++ b/体质检测管理.ipynb @@ -963,27 +963,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "93d73139-1734-49e5-a59a-15898af9b1d8", "metadata": { - "execution": { - "iopub.execute_input": "2022-08-05T07:46:15.088786Z", - "iopub.status.busy": "2022-08-05T07:46:15.088219Z", - "iopub.status.idle": "2022-08-05T07:46:15.146141Z", - "shell.execute_reply": "2022-08-05T07:46:15.145040Z", - "shell.execute_reply.started": "2022-08-05T07:46:15.088739Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ok\n" - ] - } - ], + "outputs": [], "source": [ "import pymysql\n", "import json\n", @@ -1098,31 +1083,12 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "a7cf5e57-a381-4911-96ff-1e1469b6f9bc", "metadata": { - "execution": { - "iopub.execute_input": "2022-08-05T07:49:14.416959Z", - "iopub.status.busy": "2022-08-05T07:49:14.416421Z", - "iopub.status.idle": "2022-08-05T07:49:14.474792Z", - "shell.execute_reply": "2022-08-05T07:49:14.473376Z", - "shell.execute_reply.started": "2022-08-05T07:49:14.416912Z" - }, "tags": [] }, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'bm'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;31m#print(k,v)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 44\u001b[0m \u001b[0msheet\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34mf'A{n}'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 45\u001b[0;31m \u001b[0msheet\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34mf'B{n}'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'bm'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 46\u001b[0m \u001b[0msheet\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34mf'C{n}'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'name'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 47\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'身高'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 'bm'" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import openpyxl\n", @@ -1501,7 +1467,9 @@ { "cell_type": "markdown", "id": "4d255389-bc5c-4251-861e-3a4d65bf5c26", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "## 根据体测报告生成分组表" ] @@ -2299,16 +2267,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "c288cfba-ff44-4cb2-8a77-78ecc45dcb41", "metadata": { - "execution": { - "iopub.execute_input": "2022-06-22T09:12:51.227405Z", - "iopub.status.busy": "2022-06-22T09:12:51.226182Z", - "iopub.status.idle": "2022-06-22T09:12:51.354977Z", - "shell.execute_reply": "2022-06-22T09:12:51.353040Z", - "shell.execute_reply.started": "2022-06-22T09:12:51.227296Z" - }, "tags": [] }, "outputs": [],