diff --git a/体测单位/低碳院.ipynb b/体测单位/低碳院.ipynb index f6a619f..a77e4dd 100644 --- a/体测单位/低碳院.ipynb +++ b/体测单位/低碳院.ipynb @@ -656,6 +656,53 @@ "print('ok')" ] }, + { + "cell_type": "markdown", + "id": "270af334-51d0-4c79-8639-e64fb4bb292a", + "metadata": {}, + "source": [ + "### 报告分组更名" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f0860f3a-9f63-43c9-aa39-3ee5ad8116e3", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import os,sys,shutil\n", + "import json\n", + "import math\n", + "import openpyxl\n", + "\n", + "filename = 'data/低碳院体测人员信息2023.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "\n", + "fi_path = 'file/139/2023-03-08'\n", + "m_path = 'file/139/new'\n", + "old = []\n", + "\n", + "fl=os.listdir(fi_path)\n", + "for fn in fl:\n", + " if os.path.isfile(fi_path + '/' + fn):\n", + " ofn = int(fn.split('.')[0])\n", + " old.append(ofn) \n", + "old.sort()\n", + "for n in old: \n", + " o_name = f'{fi_path}/{n}.pdf'\n", + " name = dict1[str(n)]['name']\n", + " n_name = f'{m_path}/{str(n).rjust(5,\"0\")}-{name}.pdf'\n", + " #print(o_name,n_name)\n", + " if not os.path.exists(n_name):\n", + " shutil.copyfile(o_name,n_name)\n", + " print(n_name)\n", + "\n" + ] + }, { "cell_type": "markdown", "id": "8c97bf0f-2b01-487d-bd18-200fcbe2c9b3", @@ -666,35 +713,12 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": null, "id": "bcc60f36-71aa-4d59-b4dd-55b1f95ef4f3", "metadata": { - "execution": { - "iopub.execute_input": "2023-03-23T13:10:46.922922Z", - "iopub.status.busy": "2023-03-23T13:10:46.922072Z", - "iopub.status.idle": "2023-03-23T13:10:46.938257Z", - "shell.execute_reply": "2023-03-23T13:10:46.937054Z", - "shell.execute_reply.started": "2023-03-23T13:10:46.922881Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "20~24岁平均成绩:1.82分,人数:2人\n", - "25~29岁平均成绩:3.0分,人数:13人\n", - "30~34岁平均成绩:3.01分,人数:36人\n", - "35~39岁平均成绩:3.23分,人数:41人\n", - "40~44岁平均成绩:3.05分,人数:55人\n", - "45~49岁平均成绩:2.82分,人数:14人\n", - "50~54岁平均成绩:2.88分,人数:5人\n", - "55~59岁平均成绩:2.14分,人数:5人\n", - "60~69岁平均成绩:1.45分,人数:1人\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "\n", @@ -726,27 +750,12 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": null, "id": "f0624326-7a21-4358-a036-daf03432bc80", "metadata": { - "execution": { - "iopub.execute_input": "2023-03-23T13:46:30.165738Z", - "iopub.status.busy": "2023-03-23T13:46:30.164841Z", - "iopub.status.idle": "2023-03-23T13:46:30.207376Z", - "shell.execute_reply": "2023-03-23T13:46:30.206332Z", - "shell.execute_reply.started": "2023-03-23T13:46:30.165698Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'体重': {'总体': [625, 165], '男': [310, 94], '女': [315, 71]}, '肺活量': {'总体': [651, 166], '男': [371, 95], '女': [280, 71]}, '握力': {'总体': [335, 159], '男': [191, 93], '女': [144, 66]}, '坐位体前屈': {'总体': [474, 162], '男': [248, 92], '女': [226, 70]}, '纵跳': {'总体': [515, 164], '男': [276, 94], '女': [239, 70]}, '俯卧撑': {'总体': [322, 85], '男': [322, 85]}, '一分钟仰卧起坐': {'总体': [246, 59], '女': [246, 59]}, '单脚站立': {'总体': [339, 165], '男': [169, 94], '女': [170, 71]}, '选择反应时': {'总体': [562, 164], '男': [313, 93], '女': [249, 71]}, '台阶指数': {'总体': [413, 146], '男': [239, 84], '女': [174, 62]}}\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import openpyxl\n", diff --git a/体测单位/淄博交警支队.ipynb b/体测单位/淄博交警支队.ipynb index 69ce464..a754db9 100644 --- a/体测单位/淄博交警支队.ipynb +++ b/体测单位/淄博交警支队.ipynb @@ -892,7 +892,7 @@ " dict1['unit'] = sheet.cell(n, 1).value\n", " person[phone] = dict1\n", "list1 = []\n", - "filename = 'data/Survey_20230418-psy.csv'\n", + "filename = 'data/Survey_20230424-tcm5.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -906,7 +906,7 @@ " if k not in cjry:\n", " list2.append([k,person[k]['name'],person[k]['unit']])\n", " \n", - "filename = 'data/交警支队未参加中医评估人员(20230417).xlsx'\n", + "filename = 'data/交警支队未参加中医评估人员(20230424).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "#sheet.append(title)\n", @@ -928,7 +928,9 @@ "cell_type": "code", "execution_count": null, "id": "d54bd635-c0d8-4527-811f-6d28f9cf68ae", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import openpyxl\n", @@ -940,6 +942,74 @@ "person = {}\n", "cjry = set()\n", "for n in range(2, sheet.max_row+1):\n", + " if sheet.cell(n,2).value is None:gangx\n", + " break\n", + " else: \n", + " phone = sheet.cell(n, 5).value \n", + " person.setdefault(phone, {})\n", + " dict1 = {}\n", + " dict1['name'] = sheet.cell(n, 2).value \n", + " xb = str(sheet.cell(n, 3).value)\n", + " if xb == '1':\n", + " sex = '男'\n", + " elif xb =='2':\n", + " sex = '女'\n", + " dict1['sex'] = sex\n", + " dict1['unit'] = sheet.cell(n, 1).value\n", + " person[phone] = dict1\n", + "list1 = []\n", + "filename = 'data/Survey_20230424-jj.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", + " cjry.add(line[2])\n", + "print(len(cjry))\n", + "\n", + "list2 = []\n", + "for item in cjry: \n", + " if str(item) not in person.keys():\n", + " list2.append(['','',item])\n", + "filename = 'data/交警支队缺失信息人员(20230424).xlsx'\n", + "wb = openpyxl.Workbook()\n", + "sheet = wb.active\n", + "#sheet.append(title)\n", + "for row in list2:\n", + " sheet.append(row)\n", + " \n", + "wb.save(filename)\n" + ] + }, + { + "cell_type": "markdown", + "id": "c0f7a72a-3930-4c05-bf96-e65f0f83a634", + "metadata": {}, + "source": [ + "### 统计生成报告人员情况表" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a9a871ae-ab54-4f49-ada4-438b6a3e10be", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import openpyxl\n", + "import json\n", + "import glob,os,shutil\n", + "from pathlib2 import Path\n", + "import csv\n", + "\n", + "wb = openpyxl.load_workbook('data/淄博交警支队人员名单(排序花名册).xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "person = {}\n", + "depart = []\n", + "for n in range(2, sheet.max_row+1):\n", " if sheet.cell(n,2).value is None:\n", " break\n", " else: \n", @@ -956,24 +1026,146 @@ " dict1['unit'] = sheet.cell(n, 1).value\n", " person[phone] = dict1\n", "list1 = []\n", - "filename = 'data/Survey_20230418-psy.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", - " cjry.add(line[2])\n", - "print(len(cjry))\n", - "list2 = []\n", - "for item in cjry:\n", - " if str(item) not in person.keys():\n", - " print(item)\n" + "dict1 = {}\n", + "old = []\n", + "fi_path = 'file/132/20230425'\n", + "fl=glob.glob(f'{fi_path}/*.pdf')\n", + "print(len(fl))\n", + "for fn in fl:\n", + " phone = Path(fn).stem\n", + " if phone in person.keys():\n", + " name = person[phone]['name']\n", + " unit = person[phone]['unit']\n", + " else:\n", + " name = ''\n", + " unit ='未明确部门'\n", + " if unit not in depart:\n", + " depart.append(unit)\n", + " dict1[phone] = {'name':name,'unit':unit}\n", + "print(depart)\n", + "m_path = 'file/132/new'\n", + "for pn in depart:\n", + " if not os.path.exists(m_path + '/' + pn):\n", + " os.mkdir(m_path + '/' + pn)\n", + "\n", + "fl=os.listdir(fi_path)\n", + "for fn in fl:\n", + " if os.path.isfile(fi_path + '/' + fn):\n", + " ofn = int(fn.split('.')[0])\n", + " old.append(ofn) \n", + "old.sort()\n", + "for n in old: \n", + " o_name = f'{fi_path}/{n}.pdf'\n", + " unit = dict1[str(n)]['unit']\n", + " \n", + " n_name = f'{m_path}/{unit}/{str(n)}.pdf'\n", + " #print(o_name,n_name)\n", + " if not os.path.exists(n_name):\n", + " shutil.copyfile(o_name,n_name)\n", + " print(n_name)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "790407ea-3461-4533-8775-390ea3465da9", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-25T12:17:16.457023Z", + "iopub.status.busy": "2023-04-25T12:17:16.456189Z", + "iopub.status.idle": "2023-04-25T12:17:16.698120Z", + "shell.execute_reply": "2023-04-25T12:17:16.697394Z", + "shell.execute_reply.started": "2023-04-25T12:17:16.456992Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "452\n", + "['博山大队', '桓台大队', '未明确部门', '支队', '淄川大队', '文昌湖大队', '支队车管所', '高青大队', '张店大队', '设施大队', '周村大队', '高新区大队', '支队外调人员', '沂源大队', '退休人员', '临淄大队']\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "import glob,os,shutil\n", + "from pathlib2 import Path\n", + "import csv\n", + "\n", + "wb = openpyxl.load_workbook('data/淄博交警支队人员名单(排序花名册).xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "person = {}\n", + "depart = []\n", + "for n in range(2, sheet.max_row+1):\n", + " if sheet.cell(n,2).value is None:\n", + " break\n", + " else: \n", + " phone = sheet.cell(n, 5).value \n", + " person.setdefault(phone, {})\n", + " dict1 = {}\n", + " dict1['name'] = sheet.cell(n, 2).value \n", + " xb = str(sheet.cell(n, 3).value)\n", + " if xb == '1':\n", + " sex = '男'\n", + " elif xb =='2':\n", + " sex = '女'\n", + " dict1['sex'] = sex\n", + " dict1['unit'] = sheet.cell(n, 1).value\n", + " person[phone] = dict1\n", + "list1 = []\n", + "dict1 = {}\n", + "old = []\n", + "fi_path = 'file/132/20230425'\n", + "fl=glob.glob(f'{fi_path}/*.pdf')\n", + "print(len(fl))\n", + "for fn in fl:\n", + " phone = Path(fn).stem\n", + " if phone in person.keys():\n", + " name = person[phone]['name']\n", + " unit = person[phone]['unit']\n", + " else:\n", + " name = ''\n", + " unit ='未明确部门'\n", + " if unit not in depart:\n", + " depart.append(unit)\n", + " dict1[phone] = {'name':name,'unit':unit}\n", + "print(depart)\n", + "m_path = 'file/132/new'\n", + "for pn in depart:\n", + " if not os.path.exists(m_path + '/' + pn):\n", + " os.mkdir(m_path + '/' + pn)\n", + "\n", + "fl=os.listdir(fi_path)\n", + "for fn in fl:\n", + " if os.path.isfile(fi_path + '/' + fn):\n", + " ofn = int(fn.split('.')[0])\n", + " old.append(ofn) \n", + "old.sort()\n", + "for n in old: \n", + " o_name = f'{fi_path}/{n}.pdf'\n", + " unit = dict1[str(n)]['unit'] \n", + " n_name = f'{m_path}/{unit}/{str(n)}.pdf'\n", + " list1.append([unit,n])\n", + "filename = 'data/淄博交警报告打印明细表.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", + " \n", + "wb.save(filename)" ] }, { "cell_type": "code", "execution_count": null, - "id": "908df4fc-254f-4525-a199-e0b82469af81", + "id": "c26f4d44-d58d-4a37-a117-ac4a90a67866", "metadata": {}, "outputs": [], "source": [] @@ -981,7 +1173,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -995,7 +1187,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.10.6" } }, "nbformat": 4, diff --git a/体测单位/淄博高新区.ipynb b/体测单位/淄博高新区.ipynb index e7aea6b..312c0a8 100644 --- a/体测单位/淄博高新区.ipynb +++ b/体测单位/淄博高新区.ipynb @@ -10,27 +10,12 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "6ab7bf77-5451-4773-9b13-10e04a48ddfb", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-21T06:44:50.778622Z", - "iopub.status.busy": "2023-04-21T06:44:50.777794Z", - "iopub.status.idle": "2023-04-21T06:44:51.048732Z", - "shell.execute_reply": "2023-04-21T06:44:51.047657Z", - "shell.execute_reply.started": "2023-04-21T06:44:50.778580Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ok\n" - ] - } - ], + "outputs": [], "source": [ "import openpyxl\n", "import json\n", @@ -59,6 +44,45 @@ "print('ok')" ] }, + { + "cell_type": "markdown", + "id": "176b8fca-a7aa-4949-88df-b99158bfd46b", + "metadata": {}, + "source": [ + "## 补充人员信息(部门)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c4baf116-9e8b-4820-98a7-9a468f4abb7f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import openpyxl\n", + "import json\n", + "import csv\n", + "filename = 'data/高新区.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "wb = openpyxl.load_workbook('data/高新区.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "person = {}\n", + "for n in range(2, sheet.max_row+1):\n", + " if sheet.cell(n,2).value is None:\n", + " break\n", + " else: \n", + " code = int(sheet.cell(n, 4).value)\n", + " if str(code) in dict1.keys():\n", + " dict1[str(code)]['unit'] = sheet.cell(n, 3).value\n", + "with open(filename, 'w') as fl:\n", + " json.dump(dict1, fl, ensure_ascii=False)\n", + "print('ok')" + ] + }, { "cell_type": "markdown", "id": "502638d8-79d0-4392-953e-047c8428c9a5", @@ -77,27 +101,12 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "7609f3c3-5c52-4b92-a2d5-359bf4a45a10", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-21T07:01:46.516495Z", - "iopub.status.busy": "2023-04-21T07:01:46.515666Z", - "iopub.status.idle": "2023-04-21T07:01:46.605645Z", - "shell.execute_reply": "2023-04-21T07:01:46.604904Z", - "shell.execute_reply.started": "2023-04-21T07:01:46.516452Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "213\n" - ] - } - ], + "outputs": [], "source": [ "import openpyxl\n", "import json\n", @@ -106,7 +115,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "cjry = set()\n", - "filename = 'data/Survey_20230421-psy.csv'\n", + "filename = 'data/Survey_20230424-psy.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -120,7 +129,7 @@ " if 'phone' in v.keys() and v['phone'] not in cjry:\n", " list2.append([k,dict1[str(k)]['name'],dict1[str(k)]['phone']])\n", " \n", - "filename = 'data/高新未参加心理评估人员(20230421).xlsx'\n", + "filename = 'data/高新未参加心理评估人员(20230424).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "#sheet.append(title)\n", @@ -140,27 +149,12 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "fd2391c1-8d73-4714-8c20-42161b3eb493", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-21T07:03:35.174975Z", - "iopub.status.busy": "2023-04-21T07:03:35.174533Z", - "iopub.status.idle": "2023-04-21T07:03:35.240353Z", - "shell.execute_reply": "2023-04-21T07:03:35.239435Z", - "shell.execute_reply.started": "2023-04-21T07:03:35.174944Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "217\n" - ] - } - ], + "outputs": [], "source": [ "import openpyxl\n", "import json\n", @@ -169,7 +163,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "cjry = set()\n", - "filename = 'data/Survey_20230421-tcm1.csv'\n", + "filename = 'data/Survey_20230424-tcm1.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -183,7 +177,7 @@ " if 'phone' in v.keys() and v['phone'] not in cjry:\n", " list2.append([k,dict1[str(k)]['name'],dict1[str(k)]['phone']])\n", " \n", - "filename = 'data/高新未参加中医评估人员(20230421).xlsx'\n", + "filename = 'data/高新未参加中医评估人员(20230424).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "#sheet.append(title)\n", @@ -203,27 +197,12 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "id": "fd5af221-9369-4eab-884c-06885c940d88", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-21T07:16:05.935096Z", - "iopub.status.busy": "2023-04-21T07:16:05.934235Z", - "iopub.status.idle": "2023-04-21T07:16:05.967884Z", - "shell.execute_reply": "2023-04-21T07:16:05.966719Z", - "shell.execute_reply.started": "2023-04-21T07:16:05.935054Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "235\n" - ] - } - ], + "outputs": [], "source": [ "import openpyxl\n", "import json\n", @@ -232,7 +211,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "cjry = set()\n", - "filename = 'data/Survey_20230421.csv'\n", + "filename = 'data/Survey_20230424-gx.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -249,7 +228,7 @@ "for item in cjry: \n", " if item not in phones:\n", " list2.append(['','',item])\n", - "filename = 'data/高新缺失信息人员(20230421).xlsx'\n", + "filename = 'data/高新缺失信息人员(20230424).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "#sheet.append(title)\n", @@ -259,10 +238,199 @@ "wb.save(filename)" ] }, + { + "cell_type": "markdown", + "id": "9e9dc89c-5ca1-4c2d-997a-6330df544ea0", + "metadata": {}, + "source": [ + "### 统计生成报告人员情况表" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "01933c1f-b7e8-46ff-8a52-f415fca82e27", + "id": "4c1b32b8-5cbd-430b-81fd-957e3def5155", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import glob\n", + "from pathlib2 import Path\n", + "import openpyxl\n", + "\n", + "\n", + "filename = 'data/高新区.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "list1 = []\n", + "fi_path = 'file/130/20230424'\n", + "fl=glob.glob(f'{fi_path}/*.pdf')\n", + "print(len(fl))\n", + "for fn in fl:\n", + " name = Path(fn).stem\n", + " if name in dict1.keys():\n", + " list1.append([name,dict1[name]['name']])\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", + " \n", + "wb.save(filename)" + ] + }, + { + "cell_type": "markdown", + "id": "2731b99f-8138-4e9e-baf0-c9c0c375f0eb", + "metadata": {}, + "source": [ + "### 报告分组重命名" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a9f5a1d4-4c01-4656-85f3-bdbf2776b69d", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import os,sys,shutil\n", + "import json\n", + "import math\n", + "import openpyxl\n", + "\n", + "filename = 'data/高新区.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "list1 = []\n", + "list_bh = []\n", + "depart = []\n", + "dict2 = {}\n", + "for k, v in dict1.items():\n", + " dict2.setdefault(k,{}) \n", + " \n", + " if 'unit' in v.keys():\n", + " m_depart = v['unit']\n", + " else:\n", + " m_depart = '未明确部门'\n", + " dict2[k]['unit'] = m_depart\n", + " if m_depart not in depart:\n", + " depart.append(m_depart)\n", + " dict2[k]['name'] = v['name']\n", + " \n", + "old = []\n", + "\n", + " \n", + "fi_path = 'file/130/20230424'\n", + "\n", + "\n", + "# 创建部门办公室 \n", + "m_path = 'file/130/new'\n", + "for pn in depart:\n", + " if not os.path.exists(m_path + '/' + pn):\n", + " os.mkdir(m_path + '/' + pn)\n", + "fl=os.listdir(fi_path)\n", + "for fn in fl:\n", + " if os.path.isfile(fi_path + '/' + fn):\n", + " ofn = int(fn.split('.')[0])\n", + " old.append(ofn) \n", + "old.sort()\n", + "for n in old: \n", + " o_name = f'{fi_path}/{n}.pdf'\n", + " unit = dict2[str(n)]['unit']\n", + " name = dict2[str(n)]['name']\n", + " n_name = f'{m_path}/{unit}/{str(n).rjust(5,\"0\")}-{name}.pdf'\n", + " #print(o_name,n_name)\n", + " if not os.path.exists(n_name):\n", + " shutil.copyfile(o_name,n_name)\n", + " print(n_name)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "3d0268bb-8bce-4887-a745-077a62069675", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-25T07:52:40.990776Z", + "iopub.status.busy": "2023-04-25T07:52:40.989921Z", + "iopub.status.idle": "2023-04-25T07:52:41.056793Z", + "shell.execute_reply": "2023-04-25T07:52:41.055627Z", + "shell.execute_reply.started": "2023-04-25T07:52:40.990734Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import os,sys,shutil\n", + "import json\n", + "import math\n", + "import openpyxl\n", + "\n", + "filename = 'data/高新区.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "list1 = []\n", + "list_bh = []\n", + "depart = []\n", + "dict2 = {}\n", + "for k, v in dict1.items():\n", + " dict2.setdefault(k,{}) \n", + " \n", + " if 'unit' in v.keys():\n", + " m_depart = v['unit']\n", + " else:\n", + " m_depart = '未明确部门'\n", + " dict2[k]['unit'] = m_depart\n", + " if m_depart not in depart:\n", + " depart.append(m_depart)\n", + " dict2[k]['name'] = v['name']\n", + " \n", + "old = []\n", + "\n", + " \n", + "fi_path = 'file/130/20230424'\n", + "\n", + "\n", + "# 创建部门办公室 \n", + "m_path = 'file/130/new'\n", + "for pn in depart:\n", + " if not os.path.exists(m_path + '/' + pn):\n", + " os.mkdir(m_path + '/' + pn)\n", + "fl=os.listdir(fi_path)\n", + "for fn in fl:\n", + " if os.path.isfile(fi_path + '/' + fn):\n", + " ofn = int(fn.split('.')[0])\n", + " old.append(ofn) \n", + "old.sort()\n", + "\n", + "for n in old: \n", + " o_name = f'{fi_path}/{n}.pdf'\n", + " unit = dict2[str(n)]['unit']\n", + " name = dict2[str(n)]['name']\n", + " code = str(n).rjust(5,\"0\")\n", + " list1.append([unit,code,name])\n", + "filename = 'data/高新报告打印明细表.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", + " \n", + "wb.save(filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f5910a5a-05a5-404f-b3e9-eca86226e244", "metadata": {}, "outputs": [], "source": [] diff --git a/体测单位/燕山石化.ipynb b/体测单位/燕山石化.ipynb index 0f59805..cd80dba 100644 --- a/体测单位/燕山石化.ipynb +++ b/体测单位/燕山石化.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 106, + "execution_count": 110, "id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16", "metadata": { "execution": { - "iopub.execute_input": "2023-04-24T10:05:01.926272Z", - "iopub.status.busy": "2023-04-24T10:05:01.925417Z", - "iopub.status.idle": "2023-04-24T10:05:04.468748Z", - "shell.execute_reply": "2023-04-24T10:05:04.467687Z", - "shell.execute_reply.started": "2023-04-24T10:05:01.926232Z" + "iopub.execute_input": "2023-04-25T10:41:09.138090Z", + "iopub.status.busy": "2023-04-25T10:41:09.137225Z", + "iopub.status.idle": "2023-04-25T10:41:11.696860Z", + "shell.execute_reply": "2023-04-25T10:41:11.695874Z", + "shell.execute_reply.started": "2023-04-25T10:41:09.138049Z" }, "tags": [] }, @@ -46,7 +46,11 @@ " code = int(sheet.cell(n, 1).value)\n", " person.setdefault(code, {})\n", " dict1 = {}\n", - " dict1['name'] = sheet.cell(n, 2).value \n", + " dict1['name'] = sheet.cell(n, 2).value\n", + " if sheet.cell(n, 7).value ==1:\n", + " sex = '男'\n", + " else:\n", + " sex = '女'\n", " dict1['sex'] = sheet.cell(n, 3).value\n", " birth = str(sheet.cell(n, 6).value).split()[0]\n", " dict1['birth'] = birth\n", @@ -85,15 +89,15 @@ }, { "cell_type": "code", - "execution_count": 107, + "execution_count": 111, "id": "71e1ec6a-6797-4496-969a-1d1461b9ea58", "metadata": { "execution": { - "iopub.execute_input": "2023-04-24T10:06:37.571983Z", - "iopub.status.busy": "2023-04-24T10:06:37.571077Z", - "iopub.status.idle": "2023-04-24T10:06:37.786825Z", - "shell.execute_reply": "2023-04-24T10:06:37.785861Z", - "shell.execute_reply.started": "2023-04-24T10:06:37.571941Z" + "iopub.execute_input": "2023-04-25T10:41:24.604593Z", + "iopub.status.busy": "2023-04-25T10:41:24.603754Z", + "iopub.status.idle": "2023-04-25T10:41:24.838577Z", + "shell.execute_reply": "2023-04-25T10:41:24.837823Z", + "shell.execute_reply.started": "2023-04-25T10:41:24.604553Z" }, "tags": [] }, @@ -102,10 +106,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "423\n", - "5593 刘安全 已测试!\n", - "423\n", - "2645\n" + "454\n", + "454\n", + "3099\n" ] } ], @@ -128,7 +131,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", - "filename = 'data/places_result_20230424.csv'\n", + "filename = 'data/places_result_20230425.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -161,7 +164,7 @@ " else:\n", " for k1,v1 in v.items():\n", " dict2[k][k1] = v1\n", - "filename = 'data/result_燕山石化(20230424).json'\n", + "filename = 'data/result_燕山石化(20230425).json'\n", "with open(filename,'w') as fl:\n", " json.dump(re_ta, fl, ensure_ascii=False) \n", "print(len(re_ta))\n", @@ -181,15 +184,15 @@ }, { "cell_type": "code", - "execution_count": 108, + "execution_count": 112, "id": "c24880ad-bbbd-4ad8-a894-cbcea389e822", "metadata": { "execution": { - "iopub.execute_input": "2023-04-24T10:08:16.575368Z", - "iopub.status.busy": "2023-04-24T10:08:16.574601Z", - "iopub.status.idle": "2023-04-24T10:08:16.751333Z", - "shell.execute_reply": "2023-04-24T10:08:16.750617Z", - "shell.execute_reply.started": "2023-04-24T10:08:16.575338Z" + "iopub.execute_input": "2023-04-25T10:41:45.914369Z", + "iopub.status.busy": "2023-04-25T10:41:45.913494Z", + "iopub.status.idle": "2023-04-25T10:41:46.098743Z", + "shell.execute_reply": "2023-04-25T10:41:46.098046Z", + "shell.execute_reply.started": "2023-04-25T10:41:45.914321Z" }, "tags": [] }, @@ -200,7 +203,7 @@ "\n", "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", - "filename = 'data/result_燕山石化(20230424).json'\n", + "filename = 'data/result_燕山石化(20230425).json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "\n", @@ -225,7 +228,7 @@ " else:\n", " list2.append('') \n", " list1.append(list2)\n", - "filename = 'data/燕山石化体测情况表(20230424).xlsx'\n", + "filename = 'data/燕山石化体测情况表(20230425).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -245,15 +248,15 @@ }, { "cell_type": "code", - "execution_count": 109, + "execution_count": 113, "id": "68454877-f1fe-4eed-8a48-265e428f892e", "metadata": { "execution": { - "iopub.execute_input": "2023-04-24T10:08:30.444506Z", - "iopub.status.busy": "2023-04-24T10:08:30.444058Z", - "iopub.status.idle": "2023-04-24T10:08:30.475858Z", - "shell.execute_reply": "2023-04-24T10:08:30.474801Z", - "shell.execute_reply.started": "2023-04-24T10:08:30.444476Z" + "iopub.execute_input": "2023-04-25T10:41:58.467679Z", + "iopub.status.busy": "2023-04-25T10:41:58.467274Z", + "iopub.status.idle": "2023-04-25T10:41:58.499250Z", + "shell.execute_reply": "2023-04-25T10:41:58.498205Z", + "shell.execute_reply.started": "2023-04-25T10:41:58.467652Z" }, "tags": [] }, @@ -262,7 +265,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'行政事务中心(离退中心)工会': 8, '热电厂工会': 1, '化学品厂工会': 55, '高科公司工会': 102, '炼油厂工会': 51, '有机化工厂工会': 131, '检验计量中心工会': 32, '物装中心工会': 2, '生产运行保障中心': 2, '烯烃厂工会': 6, '机关工会': 8, '合成树脂厂': 14, '消防中心工会': 2, '合成橡胶厂工会': 8, '储运厂工会': 1}\n" + "{'行政事务中心(离退中心)工会': 18, '炼油厂工会': 95, '化学品厂工会': 67, '高科公司工会': 109, '烯烃厂工会': 13, '有机化工厂工会': 98, '储运厂工会': 8, '检验计量中心工会': 16, '教育培训中心工会': 1, '合成橡胶厂工会': 10, '合成树脂厂': 10, '消防中心工会': 1, '生产运行保障中心': 1, '物装中心工会': 2, '机关工会': 5}\n" ] } ], @@ -270,7 +273,7 @@ "import json\n", "import openpyxl\n", "\n", - "filename = 'data/result_燕山石化(20230424).json'\n", + "filename = 'data/result_燕山石化(20230425).json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "dict2 = {}\n", @@ -285,7 +288,7 @@ " list2 = []\n", " list2 = [k,v]\n", " list1.append(list2)\n", - "filename = 'data/燕山石化部门测试人数情况表(20230424).xlsx'\n", + "filename = 'data/燕山石化部门测试人数情况表(20230425).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", diff --git a/体测单位/石家庄石化.ipynb b/体测单位/石家庄石化.ipynb index 0532432..3820d11 100644 --- a/体测单位/石家庄石化.ipynb +++ b/体测单位/石家庄石化.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 29, "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" + "iopub.execute_input": "2023-04-26T09:21:52.196489Z", + "iopub.status.busy": "2023-04-26T09:21:52.195668Z", + "iopub.status.idle": "2023-04-26T09:21:52.973388Z", + "shell.execute_reply": "2023-04-26T09:21:52.972674Z", + "shell.execute_reply.started": "2023-04-26T09:21:52.196448Z" }, "tags": [] }, @@ -72,15 +72,15 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 31, "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" + "iopub.execute_input": "2023-04-26T09:36:18.999273Z", + "iopub.status.busy": "2023-04-26T09:36:18.998427Z", + "iopub.status.idle": "2023-04-26T09:36:19.081109Z", + "shell.execute_reply": "2023-04-26T09:36:19.080378Z", + "shell.execute_reply.started": "2023-04-26T09:36:18.999232Z" }, "tags": [] }, @@ -89,7 +89,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "478\n", + "454\n", "ok\n" ] } @@ -113,7 +113,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", - "filename = 'data/places_result_20230424-sjz.csv'\n", + "filename = 'data/places_result_20230426-sjz.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -135,7 +135,7 @@ " 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", + "filename = 'data/result_石家庄(20230426).json'\n", "with open(filename,'w') as fl:\n", " json.dump(re_ta, fl) \n", "print('ok')" @@ -151,15 +151,15 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 32, "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" + "iopub.execute_input": "2023-04-26T09:37:10.787453Z", + "iopub.status.busy": "2023-04-26T09:37:10.786596Z", + "iopub.status.idle": "2023-04-26T09:37:10.924736Z", + "shell.execute_reply": "2023-04-26T09:37:10.923992Z", + "shell.execute_reply.started": "2023-04-26T09:37:10.787410Z" }, "tags": [] }, @@ -170,7 +170,7 @@ "\n", "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", - "filename = 'data/result_石家庄(20230424).json'\n", + "filename = 'data/result_石家庄(20230426).json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "\n", @@ -194,7 +194,7 @@ " else:\n", " list2.append('') \n", " list1.append(list2)\n", - "filename = 'data/石家庄石化体测情况表(20230424).xlsx'\n", + "filename = 'data/石家庄石化体测情况表(20230426).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -214,15 +214,15 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 33, "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" + "iopub.execute_input": "2023-04-26T09:38:27.401785Z", + "iopub.status.busy": "2023-04-26T09:38:27.401110Z", + "iopub.status.idle": "2023-04-26T09:38:27.597084Z", + "shell.execute_reply": "2023-04-26T09:38:27.596368Z", + "shell.execute_reply.started": "2023-04-26T09:38:27.401745Z" }, "tags": [] }, @@ -231,7 +231,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "1200\n", + "2140\n", "ok\n" ] } @@ -255,7 +255,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", - "filename = 'data/places_result_20230424-sjz.csv'\n", + "filename = 'data/places_result_20230426-sjzall.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -293,23 +293,24 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 35, "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" - } + "iopub.execute_input": "2023-04-26T09:42:34.825177Z", + "iopub.status.busy": "2023-04-26T09:42:34.824747Z", + "iopub.status.idle": "2023-04-26T09:42:34.875587Z", + "shell.execute_reply": "2023-04-26T09:42:34.874720Z", + "shell.execute_reply.started": "2023-04-26T09:42:34.825140Z" + }, + "tags": [] }, "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" + "{'综合办公室(党委办公室)': 19, '销运管理部': 41, '企业管理部(法律事务部)': 12, '合资运行部': 27, '消防支队': 39, '设备工程部': 44, '党群文化部(宣传工团)': 9, '检验计量中心': 180, '发展计划部计划组': 11, '物资采购中心': 52, '炼油运行一部': 112, '审计管理部': 6, '发展计划部发展规划组': 12, '财务管理部': 18, '生产技术部': 35, '党委组织部(资源管理部)': 16, '安全环保部': 26, '储运运行部': 151, '化工运行部': 267, '信息中心': 18, '热电运行部': 92, '炼油运行三部': 127, '行政事务中心': 45, '电气仪表中心': 196, '炼油运行五部': 120, '水务运行部': 133, '编组站': 49, '炼油运行二部': 113, '炼油运行四部': 168, '纪委(监督部)': 2}\n" ] } ], @@ -332,7 +333,7 @@ " list2 = []\n", " list2 = [k,v]\n", " list1.append(list2)\n", - "filename = 'data/石家庄测试名单部门情况(20230424).xlsx'\n", + "filename = 'data/石家庄测试名单部门情况(20230426).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -351,15 +352,15 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 34, "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" + "iopub.execute_input": "2023-04-26T09:39:12.083561Z", + "iopub.status.busy": "2023-04-26T09:39:12.083234Z", + "iopub.status.idle": "2023-04-26T09:39:12.148788Z", + "shell.execute_reply": "2023-04-26T09:39:12.147956Z", + "shell.execute_reply.started": "2023-04-26T09:39:12.083534Z" }, "tags": [] }, @@ -378,7 +379,7 @@ "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", + "filename = 'data/石家庄未测试名单(截至20230426).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "title =['测试编号','姓名','单位']\n", diff --git a/体测单位/长炼医院.ipynb b/体测单位/长炼医院.ipynb new file mode 100644 index 0000000..3fc8088 --- /dev/null +++ b/体测单位/长炼医院.ipynb @@ -0,0 +1,305 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d4d999fe-4890-4a14-b1e8-52dbd6d42e73", + "metadata": {}, + "source": [ + "## 导入人员信息" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "3154fc8c-0e91-4cda-ba75-666dc7bbb34d", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-26T02:09:17.305567Z", + "iopub.status.busy": "2023-04-26T02:09:17.304661Z", + "iopub.status.idle": "2023-04-26T02:09:17.783758Z", + "shell.execute_reply": "2023-04-26T02:09:17.782874Z", + "shell.execute_reply.started": "2023-04-26T02:09:17.305525Z" + }, + "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长炼医院监测花名册.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 int(sheet.cell(n, 7).value) ==1:\n", + " sex = '男'\n", + " else:\n", + " sex = '女'\n", + " dict1['sex'] = sex\n", + " birth = str(sheet.cell(n, 8).value).split()[0]\n", + " dict1['birth'] = birth\n", + " dict1['unit'] = sheet.cell(n, 3).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": "96d5b4bd-4198-4725-9005-070ac4e4f324", + "metadata": {}, + "source": [ + "## 每日成绩导入" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "4b52477e-926a-44b5-b8a0-20bff98d101d", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-26T02:03:49.859631Z", + "iopub.status.busy": "2023-04-26T02:03:49.858701Z", + "iopub.status.idle": "2023-04-26T02:03:49.891420Z", + "shell.execute_reply": "2023-04-26T02:03:49.890351Z", + "shell.execute_reply.started": "2023-04-26T02:03:49.859588Z" + }, + "tags": [] + }, + "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/长炼医院人员名单.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "rq = '20230425'\n", + "filename = f'data/places_result_{rq}.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", + "\n", + "filename = f'data/result_长炼医院({rq}).json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl, ensure_ascii=False) \n", + "print(len(re_ta))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "033cc564-4aa9-4e88-b38b-ec62a02b1661", + "metadata": {}, + "outputs": [], + "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", + "rq = '20230425'\n", + "filename = f'data/places_result_{rq}.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_长炼医院.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", + "for k in re_ta.keys():\n", + " if k in dict2.keys():\n", + " print(k,dict2[k]['name'],'已测试!')\n", + "for k, v in re_ta.items():\n", + " if k not in dict2.keys():\n", + " dict2[k] = v\n", + " else:\n", + " for k1,v1 in v.items():\n", + " dict2[k][k1] = v1\n", + "filename = f'data/result_长炼医院({rq}).json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl, ensure_ascii=False) \n", + "print(len(re_ta))\n", + "filename = 'data/result_长炼医院.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict2, fl, ensure_ascii=False) \n", + "print(len(dict2))" + ] + }, + { + "cell_type": "markdown", + "id": "f220ffba-d172-4b6f-8238-c3a2d6c87ed4", + "metadata": {}, + "source": [ + "## 每日成绩导出" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "2ffa583b-be51-40a8-bb55-de6a89d1a54a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-26T02:09:54.362083Z", + "iopub.status.busy": "2023-04-26T02:09:54.361227Z", + "iopub.status.idle": "2023-04-26T02:09:54.389991Z", + "shell.execute_reply": "2023-04-26T02:09:54.388984Z", + "shell.execute_reply.started": "2023-04-26T02:09:54.362051Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "rq = '20230425'\n", + "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "filename = f'data/result_长炼医院({rq}).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 = f'data/长炼医院体测情况表({rq}).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": "code", + "execution_count": null, + "id": "ec011c39-f6b1-40d5-b95e-bc59b7a51058", + "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 +}