From e5b346c7c36fe2b03f9b55c451217ce1a557eeaa Mon Sep 17 00:00:00 2001 From: "512song@sina.com" Date: Fri, 28 Oct 2022 10:00:40 +0800 Subject: [PATCH] 20221028 --- 体测单位/天津石化.ipynb | 110 ++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 45 deletions(-) diff --git a/体测单位/天津石化.ipynb b/体测单位/天津石化.ipynb index 53935ca..0f412fc 100644 --- a/体测单位/天津石化.ipynb +++ b/体测单位/天津石化.ipynb @@ -10,27 +10,12 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "id": "1144aaac-92a0-4bcf-aba7-096f7dd3ad3b", "metadata": { - "execution": { - "iopub.execute_input": "2022-10-26T15:14:22.185120Z", - "iopub.status.busy": "2022-10-26T15:14:22.184598Z", - "iopub.status.idle": "2022-10-26T15:14:23.499268Z", - "shell.execute_reply": "2022-10-26T15:14:23.498134Z", - "shell.execute_reply.started": "2022-10-26T15:14:22.185071Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ok\n" - ] - } - ], + "outputs": [], "source": [ "import openpyxl\n", "import json\n", @@ -67,27 +52,12 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "id": "a57ebb22-543c-4804-8d44-89984058ec1d", "metadata": { - "execution": { - "iopub.execute_input": "2022-10-26T15:13:30.118858Z", - "iopub.status.busy": "2022-10-26T15:13:30.118322Z", - "iopub.status.idle": "2022-10-26T15:13:30.350334Z", - "shell.execute_reply": "2022-10-26T15:13:30.349005Z", - "shell.execute_reply.started": "2022-10-26T15:13:30.118808Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ok\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import time\n", @@ -142,16 +112,9 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "id": "38397ad4-2bb3-4b5e-8ece-9ea11e801890", "metadata": { - "execution": { - "iopub.execute_input": "2022-10-26T15:14:26.661745Z", - "iopub.status.busy": "2022-10-26T15:14:26.661218Z", - "iopub.status.idle": "2022-10-26T15:14:27.250915Z", - "shell.execute_reply": "2022-10-26T15:14:27.249692Z", - "shell.execute_reply.started": "2022-10-26T15:14:26.661696Z" - }, "tags": [] }, "outputs": [], @@ -198,10 +161,67 @@ "wb.save(filename)" ] }, + { + "cell_type": "markdown", + "id": "1c7b219f-43cd-4bf0-971f-2c398f8db8ed", + "metadata": {}, + "source": [ + "## 按照日期进行报告分类" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "92ff6604-e754-4d74-9114-9df466a64e9f", + "id": "29c0f15b-1345-4b46-ac1d-b45ddede9641", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import time\n", + "import csv\n", + "import os,sys,shutil\n", + "import glob\n", + "\n", + "dict1 = {}\n", + "list1 = []\n", + "filename = 'data/134_2210.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", + "for result in list1:\n", + " user = str(result[4])\n", + " dict1.setdefault(user,'2022-10-01')\n", + " m_date = result[7]\n", + " if m_date> dict1[user]:\n", + " dict1[user] = m_date\n", + "rq = set() \n", + "for k, v in dict1.items():\n", + " rq.add(str(v).split(' ')[0].replace('-', '', 2))\n", + "# 创建目录\n", + "m_path = 'file/134'\n", + "for pn in rq:\n", + " if not os.path.exists(m_path + '/' + pn):\n", + " os.mkdir(m_path + '/' + pn)\n", + "fls = glob.glob(f'file/*.pdf')\n", + "for fn in fls:\n", + " #old = os.path.basename(fn).split('.')[0].rjust(8,'0') \n", + " old = os.path.basename(fn).split('.')[0]\n", + " mrq = str(dict1[old]).split(' ')[0].replace('-', '', 2)\n", + " n_name = f'{m_path}/{mrq}/{str(old).rjust(8,\"0\")}_{mrq}.pdf'\n", + " if not os.path.exists(n_name):\n", + " shutil.copyfile(fn,n_name)\n", + "print('ok!')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "eb24c1be-b5d3-4e61-a432-854a887746d4", "metadata": {}, "outputs": [], "source": [] @@ -209,7 +229,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -223,7 +243,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.10.6" } }, "nbformat": 4,