From 4f3910b21684db10c8cb2f72da5a876f87290e31 Mon Sep 17 00:00:00 2001 From: 512song Date: Wed, 18 Oct 2023 21:16:16 +0800 Subject: [PATCH] 20231018 --- 体测单位/天津石化.ipynb | 124 ++++++++++++++++++++++++++++++---------- 1 file changed, 95 insertions(+), 29 deletions(-) diff --git a/体测单位/天津石化.ipynb b/体测单位/天津石化.ipynb index 0eb2e74..f70f19e 100644 --- a/体测单位/天津石化.ipynb +++ b/体测单位/天津石化.ipynb @@ -2211,38 +2211,12 @@ }, { "cell_type": "code", - "execution_count": 191, + "execution_count": null, "id": "906fa6c6-3446-4176-a443-fe16e52a8a3a", "metadata": { - "execution": { - "iopub.execute_input": "2023-10-18T07:58:05.208288Z", - "iopub.status.busy": "2023-10-18T07:58:05.207897Z", - "iopub.status.idle": "2023-10-18T07:58:05.392471Z", - "shell.execute_reply": "2023-10-18T07:58:05.391914Z", - "shell.execute_reply.started": "2023-10-18T07:58:05.208259Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1736682 刘志勇\n", - "1739548 王小奎\n", - "1739773 赵东健\n", - "1733948 邱仪金\n", - "1738852 陈黎\n", - "1738874 王竫\n", - "1731037 王庆和\n", - "1732087 于晓原\n", - "1731095 张莉英\n", - "1730684 黄金龙\n", - "1730835 李朋\n", - "1730844 董振华\n" - ] - } - ], + "outputs": [], "source": [ "import os,sys,shutil\n", "import json\n", @@ -2266,10 +2240,102 @@ " print(k,v['name'])" ] }, + { + "cell_type": "markdown", + "id": "cb587095-1a0c-4ab1-b9e5-e9e5b0d52cee", + "metadata": {}, + "source": [ + "## 报告按部门分类" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "b455e8e9-cbfc-4d90-8be8-bc10d968e0cf", + "id": "3fa6a1a9-63af-4f4e-9d30-b94f4357f7dc", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import os,sys,shutil\n", + "import json\n", + "import glob\n", + "from pathlib import Path\n", + "\n", + "fi_path = '/home/songyi/pdf-typescript-old2/134'\n", + "new_path = 'file/134'\n", + "old = []\n", + "dict2 = {}\n", + "\n", + "filename = 'data/天津石化人员名单2023.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "fls = glob.glob(f'{fi_path}/*.pdf')\n", + "for fn in fls:\n", + " fi_name =Path(fn).stem.split('-')[0]\n", + " code = int(fi_name)\n", + " unit_path = Path(new_path,dict1[str(code)]['unit'])\n", + " unit_path.mkdir(parents = True, exist_ok = True)\n", + " n_name = Path(unit_path,Path(fn).stem+'.pdf')\n", + " if not os.path.exists(n_name):\n", + " shutil.copyfile(fn,n_name)\n", + " #print(n_name)" + ] + }, + { + "cell_type": "markdown", + "id": "fdcd8ea1-21ab-48ab-b7cc-0dad65b06bf2", + "metadata": {}, + "source": [ + "## 生成体测报告打印明细表" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "623671be-cef0-4a2c-bf1a-889ab159760f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import os,sys,shutil\n", + "import json\n", + "import glob\n", + "from pathlib import Path\n", + "import openpyxl\n", + "\n", + "fi_path = '/home/songyi/pdf-typescript-old2/134'\n", + "\n", + "filename = 'data/天津石化人员名单2023.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "fls = glob.glob(f'{fi_path}/*.pdf')\n", + "list1 = []\n", + "for fn in fls:\n", + " list2 = []\n", + " fi_name =Path(fn).stem.split('-')[0] \n", + " code = int(fi_name)\n", + " unit = dict1[str(code)]['unit']\n", + " list2 = [fi_name,Path(fn).stem.split('-')[1],unit]\n", + " \n", + " list1.append(list2)\n", + "print(list1)\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) \n", + "print('ok')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8157084e-67a1-48d9-a3c2-34ea8b170039", "metadata": {}, "outputs": [], "source": []