20211018
This commit is contained in:
1 parent
3585e7e9c8
commit
416a65c303
1 file changed
+58
-62
+58
-62
@@ -69,27 +69,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 77,
|
"execution_count": null,
|
||||||
"id": "91a8f4f4-c417-4db7-94ba-2d3404e5c2c9",
|
"id": "91a8f4f4-c417-4db7-94ba-2d3404e5c2c9",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2021-10-18T02:34:07.188682Z",
|
|
||||||
"iopub.status.busy": "2021-10-18T02:34:07.187761Z",
|
|
||||||
"iopub.status.idle": "2021-10-18T02:34:07.230533Z",
|
|
||||||
"shell.execute_reply": "2021-10-18T02:34:07.227725Z",
|
|
||||||
"shell.execute_reply.started": "2021-10-18T02:34:07.188577Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok!\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import pymongo\n",
|
"import pymongo\n",
|
||||||
"from bson.objectid import ObjectId\n",
|
"from bson.objectid import ObjectId\n",
|
||||||
@@ -179,27 +164,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 79,
|
"execution_count": null,
|
||||||
"id": "82e1b982-3c88-4f01-ad94-49177c4a46f6",
|
"id": "82e1b982-3c88-4f01-ad94-49177c4a46f6",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2021-10-18T02:36:32.491973Z",
|
|
||||||
"iopub.status.busy": "2021-10-18T02:36:32.491036Z",
|
|
||||||
"iopub.status.idle": "2021-10-18T02:36:34.395918Z",
|
|
||||||
"shell.execute_reply": "2021-10-18T02:36:34.393177Z",
|
|
||||||
"shell.execute_reply.started": "2021-10-18T02:36:32.491866Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"<pymongo.results.InsertManyResult object at 0x7f6f28531ec0>\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import pymongo\n",
|
"import pymongo\n",
|
||||||
@@ -250,7 +220,6 @@
|
|||||||
" dict3['sn'] = k\n",
|
" dict3['sn'] = k\n",
|
||||||
" dict3['result'] = res[k]\n",
|
" dict3['result'] = res[k]\n",
|
||||||
" dict2['exam'].append(dict3)\n",
|
" dict2['exam'].append(dict3)\n",
|
||||||
"\n",
|
|
||||||
" list1.append(dict2)\n",
|
" list1.append(dict2)\n",
|
||||||
"x = mycol.insert_many(list1)\n",
|
"x = mycol.insert_many(list1)\n",
|
||||||
"mycol1 = mydb[\"event\"]\n",
|
"mycol1 = mydb[\"event\"]\n",
|
||||||
@@ -303,14 +272,6 @@
|
|||||||
" "
|
" "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "44149ba0-1730-43d4-b07f-82a53dca4ce4",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "2bb3cbdd-9fe1-4345-8c5a-53acb1a386de",
|
"id": "2bb3cbdd-9fe1-4345-8c5a-53acb1a386de",
|
||||||
@@ -321,29 +282,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 75,
|
"execution_count": null,
|
||||||
"id": "910c3fcd-121a-42c0-9465-ad79a5829239",
|
"id": "910c3fcd-121a-42c0-9465-ad79a5829239",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2021-10-18T02:29:20.586805Z",
|
|
||||||
"iopub.status.busy": "2021-10-18T02:29:20.585860Z",
|
|
||||||
"iopub.status.idle": "2021-10-18T02:29:24.051120Z",
|
|
||||||
"shell.execute_reply": "2021-10-18T02:29:24.049117Z",
|
|
||||||
"shell.execute_reply.started": "2021-10-18T02:29:20.586699Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"\n",
|
|
||||||
"运动项目信息:\n",
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import pymysql\n",
|
"import pymysql\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -542,10 +486,62 @@
|
|||||||
"print(item['1'])"
|
"print(item['1'])"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "c47e9547-d896-4fe2-8f70-8635c92fa792",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 压缩体检报告"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "1ccab0f2-448b-4423-ae21-aa1c0f6470da",
|
"id": "1ccab0f2-448b-4423-ae21-aa1c0f6470da",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from pdf2image import convert_from_path, convert_from_bytes\n",
|
||||||
|
"import img2pdf \n",
|
||||||
|
"import glob\n",
|
||||||
|
"import os,sys\n",
|
||||||
|
"import tempfile\n",
|
||||||
|
"from pdf2image.exceptions import (\n",
|
||||||
|
" PDFInfoNotInstalledError,\n",
|
||||||
|
" PDFPageCountError,\n",
|
||||||
|
" PDFSyntaxError\n",
|
||||||
|
")\n",
|
||||||
|
"#images = convert_from_path('1.pdf',dpi=200,fmt='jpg', output_folder='./sample_data')\n",
|
||||||
|
"fl_path = 'file/210924'\n",
|
||||||
|
"new_path ='file/new'\n",
|
||||||
|
"old = glob.glob(f'{fl_path}/*.pdf')\n",
|
||||||
|
"old.sort()\n",
|
||||||
|
"for old_file in old:\n",
|
||||||
|
" s = os.path.basename(old_file).split('.')[0].rjust(5,'0')\n",
|
||||||
|
" new_file = f'{new_path}/{s}.pdf'\n",
|
||||||
|
" \n",
|
||||||
|
" with tempfile.TemporaryDirectory() as path:\n",
|
||||||
|
" images_from_path = convert_from_path(old_file, dpi=100,fmt='jpg', output_folder=path)\n",
|
||||||
|
" fl=glob.glob(f'{path}/*.jpg')\n",
|
||||||
|
" fl.sort()\n",
|
||||||
|
" a4inpt = (img2pdf.mm_to_pt(210),img2pdf.mm_to_pt(297))\n",
|
||||||
|
" layout_fun = img2pdf.get_layout_fun(a4inpt)\n",
|
||||||
|
" with open(new_file,\"wb\") as f:\n",
|
||||||
|
" f.write(img2pdf.convert(fl,layout_fun=layout_fun))\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
" #print(path)\n",
|
||||||
|
"\n",
|
||||||
|
" print(new_file,'ok')\n",
|
||||||
|
"#print(old)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "5af86665-8abc-493d-a47f-fd9c53b8caea",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
Reference in new issue
Block a user