This commit is contained in:
512song@sina.com committed 2022-11-27 18:59:23 +08:00
1 parent 4e7890b05d
commit 0a937941d1
1 file changed
+164 -94
+164 -94
View File
@@ -10,27 +10,12 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "1144aaac-92a0-4bcf-aba7-096f7dd3ad3b",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-22T11:15:25.211385Z",
"iopub.status.busy": "2022-11-22T11:15:25.211078Z",
"iopub.status.idle": "2022-11-22T11:15:26.072431Z",
"shell.execute_reply": "2022-11-22T11:15:26.071541Z",
"shell.execute_reply.started": "2022-11-22T11:15:25.211360Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
@@ -68,27 +53,12 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"id": "a57ebb22-543c-4804-8d44-89984058ec1d",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-24T05:37:24.783810Z",
"iopub.status.busy": "2022-11-24T05:37:24.783502Z",
"iopub.status.idle": "2022-11-24T05:37:25.128566Z",
"shell.execute_reply": "2022-11-24T05:37:25.127750Z",
"shell.execute_reply.started": "2022-11-24T05:37:24.783783Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -143,16 +113,9 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "38397ad4-2bb3-4b5e-8ece-9ea11e801890",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-22T11:15:35.472641Z",
"iopub.status.busy": "2022-11-22T11:15:35.472362Z",
"iopub.status.idle": "2022-11-22T11:15:36.491702Z",
"shell.execute_reply": "2022-11-22T11:15:36.490980Z",
"shell.execute_reply.started": "2022-11-22T11:15:35.472615Z"
},
"tags": []
},
"outputs": [],
@@ -209,27 +172,12 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"id": "27529013-f3de-4e23-980d-f62203e4df88",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-24T05:37:32.938028Z",
"iopub.status.busy": "2022-11-24T05:37:32.937781Z",
"iopub.status.idle": "2022-11-24T05:37:34.623378Z",
"shell.execute_reply": "2022-11-24T05:37:34.622584Z",
"shell.execute_reply.started": "2022-11-24T05:37:32.938006Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
@@ -376,6 +324,158 @@
"print('ok!')"
]
},
{
"cell_type": "markdown",
"id": "d9061d26-b09b-4bff-af24-a14adda3d83f",
"metadata": {},
"source": [
"## 按照部门报告分组"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7ea2541f-461f-4eb5-860d-4b56d6be74ab",
"metadata": {},
"outputs": [],
"source": [
"import os,sys,shutil\n",
"import json\n",
"import math\n",
"import glob\n",
"from pathlib import Path\n",
"\n",
"fi_path = './file'\n",
"old = []\n",
"dict2 = {}\n",
"\n",
"\n",
"filename = 'data/天津石化人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"for k, v in dict1.items():\n",
" m_name = v['name']\n",
" m_depart = v['unit'] \n",
" dict2[int(k)] = [m_name,m_depart]\n",
"\n",
"\n",
"\n",
"fls = glob.glob(f'./file/*.pdf')\n",
"\n",
"for fn in fls:\n",
" old.append(os.path.basename(fn).split('.')[0])\n",
" #print(fn)\n",
"\n",
"\n",
"for n in old: \n",
" o_name = f'{fi_path}/{n}.pdf'\n",
" if not os.path.exists(f'{fi_path}/new/{dict2[int(n)][1]}'):\n",
" os.mkdir(f'{fi_path}/new/{dict2[int(n)][1]}') \n",
" n_name = f'{fi_path}/new/{dict2[int(n)][1]}/{str(n).rjust(5,\"0\")}-{dict2[int(n)][0]}.pdf'\n",
" if not os.path.exists(n_name):\n",
" shutil.copyfile(o_name,n_name)\n",
" print(n_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "63eb8a23-4876-4be6-8800-1a67df8773ff",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os,sys,shutil\n",
"import json\n",
"import math\n",
"import glob\n",
"from pathlib import Path\n",
"\n",
"fi_path = './file'\n",
"old = []\n",
"dict2 = {}\n",
"\n",
"\n",
"filename = 'data/天津石化人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"for k, v in dict1.items():\n",
" m_name = v['name']\n",
" m_depart = v['unit'] \n",
" dict2[int(k)] = [m_name,m_depart]\n",
"\n",
"\n",
"\n",
"fls = glob.glob(f'./file/*.pdf')\n",
"\n",
"for fn in fls:\n",
" old.append(os.path.basename(fn).split('.')[0])\n",
"\n",
"for n in old: \n",
" o_name = f'{fi_path}/{n}.pdf'\n",
" new_path = Path('file/new',dict1[n]['unit'],dict1[n]['sub_unit'])\n",
" new_path.mkdir(parents = True, exist_ok = True)\n",
" n_name = Path(new_path,f'{str(n).rjust(7,\"0\")}-{dict2[int(n)][0]}.pdf')\n",
" if not os.path.exists(n_name):\n",
" shutil.copyfile(o_name,n_name)\n",
" print(n_name)\n",
" \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "e4590323-6645-450a-8055-756a5bf35b34",
"metadata": {},
"source": [
"## 统计报告人员信息表"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "ed681a0d-4ee8-48ec-ab05-23da7156a44e",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-26T18:05:46.062534Z",
"iopub.status.busy": "2022-11-26T18:05:46.062001Z",
"iopub.status.idle": "2022-11-26T18:05:46.353459Z",
"shell.execute_reply": "2022-11-26T18:05:46.352749Z",
"shell.execute_reply.started": "2022-11-26T18:05:46.062456Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"import os\n",
"import glob\n",
"\n",
"filename = 'data/天津石化人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"m_path ='./file'\n",
"fls = glob.glob(f'file/*.pdf')\n",
"list1 = []\n",
"for fn in fls:\n",
" list2 = []\n",
" code = os.path.basename(fn).split('.')[0]\n",
" list2 = [code.rjust(7,\"0\"),dict1[code]['name'],dict1[code]['unit'],dict1[code]['sub_unit']]\n",
" list1.append(list2)\n",
"title = ['编号','姓名','单位/部门','车间/科室',] \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": "838ec7d3-137c-4ccd-9f16-7b6312d1ffa6",
@@ -428,7 +528,7 @@
" covert2pic(zoom)\n",
" pic2pdf(obj)\n",
" \n",
"fi_path = 'file/134/20221111/'\n",
"fi_path = 'file/134/20221122/'\n",
"fl = glob.glob(f'{fi_path}*.pdf')\n",
"\n",
"for fn in fl:\n",
@@ -450,27 +550,12 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"id": "daef91be-1b58-4fb1-b182-64f43c07c90f",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-22T12:27:28.133048Z",
"iopub.status.busy": "2022-11-22T12:27:28.132742Z",
"iopub.status.idle": "2022-11-22T12:27:28.320603Z",
"shell.execute_reply": "2022-11-22T12:27:28.319820Z",
"shell.execute_reply.started": "2022-11-22T12:27:28.133020Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
@@ -535,27 +620,12 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"id": "32b61559-4495-4fbe-8eb6-2614e6225b5c",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-22T12:25:04.603031Z",
"iopub.status.busy": "2022-11-22T12:25:04.602768Z",
"iopub.status.idle": "2022-11-22T12:25:04.677363Z",
"shell.execute_reply": "2022-11-22T12:25:04.676559Z",
"shell.execute_reply.started": "2022-11-22T12:25:04.603008Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4741 6493\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",