20240226
This commit is contained in:
1 parent
e27c8e6423
commit
ca3c528084
2 files changed
+165
-12
No files matched your search
+132
-7
@@ -1306,6 +1306,8 @@
|
||||
" psy[44] = []\n",
|
||||
" dict1[k1]['psy'] = psy\n",
|
||||
" if 'tcm' in item[1]:\n",
|
||||
" if tcm[40] ==0:\n",
|
||||
" tcm[40] =1\n",
|
||||
" dict1[k1]['tcm'] = tcm\n",
|
||||
" if 'spine' in item[1]:\n",
|
||||
" dict1[k1]['spine'] = spine\n",
|
||||
@@ -1485,15 +1487,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"execution_count": 31,
|
||||
"id": "49880f85-6cda-44a6-a77f-3abd10672d7a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-01-17T04:40:13.175154Z",
|
||||
"iopub.status.busy": "2024-01-17T04:40:13.174675Z",
|
||||
"iopub.status.idle": "2024-01-17T04:40:29.104763Z",
|
||||
"shell.execute_reply": "2024-01-17T04:40:29.103968Z",
|
||||
"shell.execute_reply.started": "2024-01-17T04:40:13.175118Z"
|
||||
"iopub.execute_input": "2024-01-17T05:24:47.910905Z",
|
||||
"iopub.status.busy": "2024-01-17T05:24:47.910416Z",
|
||||
"iopub.status.idle": "2024-01-17T05:25:11.510859Z",
|
||||
"shell.execute_reply": "2024-01-17T05:25:11.510166Z",
|
||||
"shell.execute_reply.started": "2024-01-17T05:24:47.910864Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -1558,10 +1560,133 @@
|
||||
"print(i)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "56a753ee-461e-47de-bf36-58e0bb8971e1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 报告添加水印"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"id": "fc195748-7e7e-4484-9f86-a430e1da79ad",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-02-26T08:58:53.318141Z",
|
||||
"iopub.status.busy": "2024-02-26T08:58:53.317932Z",
|
||||
"iopub.status.idle": "2024-02-26T08:58:57.023478Z",
|
||||
"shell.execute_reply": "2024-02-26T08:58:57.023026Z",
|
||||
"shell.execute_reply.started": "2024-02-26T08:58:53.318126Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os,sys,shutil\n",
|
||||
"import json\n",
|
||||
"import glob\n",
|
||||
"from pathlib import Path\n",
|
||||
"import PyPDF2\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"pdfWriter = PyPDF2.PdfWriter() \n",
|
||||
"\n",
|
||||
"fi_path = '/home/songyi/pdf-typescript/安庆职工健康提升'\n",
|
||||
"new_path = 'file/安庆健康志愿者'\n",
|
||||
"\n",
|
||||
"dict1 ={}\n",
|
||||
"wb = openpyxl.load_workbook('data/安庆健康志愿者分组情况表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" code = str(sheet.cell(n, 1).value)\n",
|
||||
" dict1[code] = sheet.cell(n, 3).value\n",
|
||||
" \n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||||
"for fn in fls:\n",
|
||||
" reader = PyPDF2.PdfReader(fn)\n",
|
||||
" writer = PyPDF2.PdfWriter()\n",
|
||||
" num = len(reader.pages)\n",
|
||||
" code =str(int(Path(fn).stem.split('-')[0]))\n",
|
||||
" if code in dict1.keys():\n",
|
||||
" sy_fn = 'data/water/'+dict1[code]+'.pdf'\n",
|
||||
" water = PyPDF2.PdfReader(sy_fn).pages[0]\n",
|
||||
" for i in range(num):\n",
|
||||
" page = reader.pages[i]\n",
|
||||
" if i == num -1:\n",
|
||||
" page.merge_page(water)\n",
|
||||
" writer.add_page(page)\n",
|
||||
" with open(f'file/安庆健康志愿者/{Path(fn).stem}.pdf', 'wb') as target_file:\n",
|
||||
" writer.write(target_file)\n",
|
||||
" \n",
|
||||
"print('ok!') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"id": "c3026771-202b-44ed-b94c-7c8a57089cd2",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-02-26T08:53:24.880683Z",
|
||||
"iopub.status.busy": "2024-02-26T08:53:24.880275Z",
|
||||
"iopub.status.idle": "2024-02-26T08:53:24.904212Z",
|
||||
"shell.execute_reply": "2024-02-26T08:53:24.902898Z",
|
||||
"shell.execute_reply.started": "2024-02-26T08:53:24.880652Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'0016': '平和', '0017': '平和', '0047': '平和', '0072': '平和', '0080': '平和', '0099': '平和', '0019': '气虚', '0021': '气虚', '0025': '气虚', '0039': '气虚', '0044': '气虚', '0046': '气虚', '0051': '气虚', '0053': '气虚', '0064': '气虚', '0066': '气虚', '0068': '气虚', '0069': '气虚', '0074': '气虚', '0084': '气虚', '0036': '气郁', '0048': '气郁', '0050': '气郁', '0056': '气郁', '0062': '气郁', '0065': '气郁', '0070': '气郁', '0073': '气郁', '0097': '气郁', '0001': '湿热', '0008': '湿热', '0011': '湿热', '0014': '湿热', '0038': '湿热', '0057': '湿热', '0058': '湿热', '0090': '湿热', '0093': '湿热', '0095': '湿热', '0100': '湿热', '0009': '痰湿', '0012': '痰湿', '0015': '痰湿', '0020': '痰湿', '0026': '痰湿', '0030': '痰湿', '0041': '痰湿', '0077': '痰湿', '0079': '痰湿', '0083': '痰湿', '0085': '痰湿', '0089': '痰湿', '0094': '痰湿', '0101': '痰湿', '0010': '特禀', '0023': '特禀', '0055': '特禀', '0013': '特禀', '0022': '特禀', '0035': '特禀', '0049': '特禀', '0081': '特禀', '0082': '特禀', '0004': '阳虚', '0005': '阳虚', '0006': '阳虚', '0018': '阳虚', '0028': '阳虚', '0029': '阳虚', '0032': '阳虚', '0033': '阳虚', '0034': '阳虚', '0037': '阳虚', '0040': '阳虚', '0045': '阳虚', '0052': '阳虚', '0054': '阳虚', '0059': '阳虚', '0060': '阳虚', '0061': '阳虚', '0063': '阳虚', '0071': '阳虚', '0075': '阳虚', '0076': '阳虚', '0086': '阳虚', '0091': '阳虚', '0092': '阳虚', '0096': '阳虚', '0002': '阴虚', '0003': '阴虚', '0007': '阴虚', '0027': '阴虚', '0031': '阴虚', '0042': '阴虚', '0078': '阴虚', '0088': '阴虚'}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os,sys,shutil\n",
|
||||
"import json\n",
|
||||
"import glob\n",
|
||||
"from pathlib import Path\n",
|
||||
"import PyPDF2\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"pdfWriter = PyPDF2.PdfWriter() \n",
|
||||
"\n",
|
||||
"fi_path = '/home/songyi/python/mycrm/flask/pdf/files/309118_1'\n",
|
||||
"new_path = 'file/309118_sy'\n",
|
||||
"\n",
|
||||
"dict1 ={}\n",
|
||||
"wb = openpyxl.load_workbook('data/安庆健康志愿者分组情况表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" code = str(sheet.cell(n, 1).value).rjust(4,\"0\")\n",
|
||||
" dict1[code] = sheet.cell(n, 3).value\n",
|
||||
"print(dict1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "319df381-b4fc-4795-8769-df9cd25bd04a",
|
||||
"id": "cac96c1b-62a6-4301-af95-9200a283f4b4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user