20260122
This commit is contained in:
1 parent
72a94b8de3
commit
262b081f94
6 files changed
+958
-650
No files matched your search
@@ -64,6 +64,67 @@
|
|||||||
"#print(dict1)"
|
"#print(dict1)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "bb7b6152-0fad-4917-912a-379ed49c06f9",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 批量修改文件名"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d8abca28-6e1f-4f0a-a715-c1697cdf3f6a",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import os,sys,shutil\n",
|
||||||
|
"import json\n",
|
||||||
|
"import glob\n",
|
||||||
|
"from pathlib import Path\n",
|
||||||
|
"\n",
|
||||||
|
"filepath = 'file/line/'\n",
|
||||||
|
"new = 'file/Line1/'\n",
|
||||||
|
"files = glob.glob(f'{filepath}*.SAC')\n",
|
||||||
|
"for fn in files:\n",
|
||||||
|
" fi_name =Path(fn).stem.split('_')[0]\n",
|
||||||
|
" n_name = Path(new,fi_name+'.SAC')\n",
|
||||||
|
" shutil.copyfile(fn,n_name)\n",
|
||||||
|
" \n",
|
||||||
|
" "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e22401f7-9c02-4c4b-a935-e844e56d099b",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 汇总目录下所有文件"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "62ff063a-5380-4e08-b115-acd967441ca4",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import os,sys,shutil\n",
|
||||||
|
"from pathlib import Path\n",
|
||||||
|
"\n",
|
||||||
|
"fi_path = Path('file/北海/2022年')\n",
|
||||||
|
"new_path = 'file/北海/new/2022年'\n",
|
||||||
|
"pdf_files = list(fi_path.glob('**/*.pdf'))\n",
|
||||||
|
"fls = list(fi_path.glob('**/*.pdf'))\n",
|
||||||
|
"for fn in fls:\n",
|
||||||
|
" fi_name =Path(fn).name\n",
|
||||||
|
" n_name = Path(new_path,fi_name)\n",
|
||||||
|
" shutil.copyfile(fn,n_name)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -530,6 +591,22 @@
|
|||||||
" "
|
" "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "35b46e24-cbcd-4975-bd69-b75b886e7347",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "da9d533f-3b61-4628-8d1e-470aa0a493a8",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "d936ca99-269b-46f8-8582-fb02ed2cd3cc",
|
"id": "d936ca99-269b-46f8-8582-fb02ed2cd3cc",
|
||||||
@@ -933,16 +1010,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": null,
|
||||||
"id": "52db5faa-ed27-4ac1-a9e0-b260d8737eb6",
|
"id": "52db5faa-ed27-4ac1-a9e0-b260d8737eb6",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2022-10-05T01:52:52.306098Z",
|
|
||||||
"iopub.status.busy": "2022-10-05T01:52:52.305370Z",
|
|
||||||
"iopub.status.idle": "2022-10-05T01:52:53.053478Z",
|
|
||||||
"shell.execute_reply": "2022-10-05T01:52:53.052957Z",
|
|
||||||
"shell.execute_reply.started": "2022-10-05T01:52:52.305888Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -960,10 +1030,7 @@
|
|||||||
"for fn in fl:\n",
|
"for fn in fl:\n",
|
||||||
" doc = fitz.open(fn)\n",
|
" doc = fitz.open(fn)\n",
|
||||||
" doc2.insert_pdf(doc, from_page = 1,to_page = 1)\n",
|
" doc2.insert_pdf(doc, from_page = 1,to_page = 1)\n",
|
||||||
"doc2.save(\"检查.pdf\") \n",
|
"doc2.save(\"检查.pdf\") \n"
|
||||||
" \n",
|
|
||||||
" \n",
|
|
||||||
"\n"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1002,7 +1069,7 @@
|
|||||||
" s = os.path.basename(fn).split('.')[0].rjust(5,'0') \n",
|
" s = os.path.basename(fn).split('.')[0].rjust(5,'0') \n",
|
||||||
" lurl=f'pic/{s}.jpg'\n",
|
" lurl=f'pic/{s}.jpg'\n",
|
||||||
" pm.save(lurl) \n",
|
" pm.save(lurl) \n",
|
||||||
"fitz.\n",
|
"\n",
|
||||||
"fl=glob.glob('./pic/*.jpg')\n",
|
"fl=glob.glob('./pic/*.jpg')\n",
|
||||||
"fl.sort()\n",
|
"fl.sort()\n",
|
||||||
"a4inpt = (img2pdf.mm_to_pt(210),img2pdf.mm_to_pt(297))\n",
|
"a4inpt = (img2pdf.mm_to_pt(210),img2pdf.mm_to_pt(297))\n",
|
||||||
@@ -1013,29 +1080,62 @@
|
|||||||
"print('ok!')"
|
"print('ok!')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "fcc0b4d6-9c41-4d8e-8362-36355f8c9354",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 多线程提取图片"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": null,
|
||||||
"id": "6e7c67f9-0bef-4860-9dc5-2c8fee885fd4",
|
"id": "21e20dcb-1852-4357-a08c-9ee9eacfc96b",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2022-10-05T01:53:22.899805Z",
|
|
||||||
"iopub.status.busy": "2022-10-05T01:53:22.899116Z",
|
|
||||||
"iopub.status.idle": "2022-10-05T01:59:52.903430Z",
|
|
||||||
"shell.execute_reply": "2022-10-05T01:59:52.902838Z",
|
|
||||||
"shell.execute_reply.started": "2022-10-05T01:53:22.899730Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
"source": [
|
||||||
"name": "stdout",
|
"import fitz\n",
|
||||||
"output_type": "stream",
|
"import os\n",
|
||||||
"text": [
|
"import glob\n",
|
||||||
"ok!\n"
|
"from multiprocessing.dummy import Pool\n",
|
||||||
]
|
"\n",
|
||||||
}
|
"def get_image(fn):\n",
|
||||||
],
|
" doc = fitz.open(fn)\n",
|
||||||
|
" zoom = 100\n",
|
||||||
|
" page = doc[1]\n",
|
||||||
|
" trans = fitz.Matrix(zoom / 100.0, zoom / 100.0)\n",
|
||||||
|
" pm = page.get_pixmap(matrix=trans)\n",
|
||||||
|
" s = os.path.basename(fn).split('.')[0].rjust(5,'0') \n",
|
||||||
|
" lurl=f'pic1/{s}.jpg'\n",
|
||||||
|
" pm.save(lurl)\n",
|
||||||
|
" print(f'{s}已成功生成!') \n",
|
||||||
|
"fi_path = 'file/2/'\n",
|
||||||
|
"fl = glob.glob(f'{fi_path}*.pdf')\n",
|
||||||
|
"pool = Pool(8)\n",
|
||||||
|
"pool.map(get_image,fl)\n",
|
||||||
|
"pool.close()\n",
|
||||||
|
"pool.join()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "264d3c99-a112-4ade-abda-7785bf8c0d1c",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 提取页面并分卷压缩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6e7c67f9-0bef-4860-9dc5-2c8fee885fd4",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"import glob\n",
|
"import glob\n",
|
||||||
@@ -1166,7 +1266,7 @@
|
|||||||
"import json\n",
|
"import json\n",
|
||||||
"import re\n",
|
"import re\n",
|
||||||
"\n",
|
"\n",
|
||||||
"file = \"file/1_中石化北海炼化2020年团体体检报告.pdf\"\n",
|
"file = \"file/01730823-邵希强.pdf\"\n",
|
||||||
"pdf = pdfplumber.open(file)\n",
|
"pdf = pdfplumber.open(file)\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"dict1 = {}\n",
|
"dict1 = {}\n",
|
||||||
@@ -1230,36 +1330,6 @@
|
|||||||
"pdf.close()"
|
"pdf.close()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "71e1da77-6744-4d86-a4bc-88feeb3023e8",
|
|
||||||
"metadata": {
|
|
||||||
"tags": []
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"import pdfplumber\n",
|
|
||||||
"import json\n",
|
|
||||||
"import re\n",
|
|
||||||
"\n",
|
|
||||||
"file = \"file/1_中石化北海炼化2020年团体体检报告.pdf\"\n",
|
|
||||||
"pdf = pdfplumber.open(file)\n",
|
|
||||||
"list1 = []\n",
|
|
||||||
"dict1 = {}\n",
|
|
||||||
"n = 1\n",
|
|
||||||
"for page in pdf.pages:\n",
|
|
||||||
" for pdf_table in page.extract_tables():\n",
|
|
||||||
" list2 = []\n",
|
|
||||||
" table = []\n",
|
|
||||||
" cells = []\n",
|
|
||||||
" for row in pdf_table:\n",
|
|
||||||
" print(row)\n",
|
|
||||||
" print('******')\n",
|
|
||||||
" print('--------')\n",
|
|
||||||
" "
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -1269,15 +1339,14 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import camelot\n",
|
"import pdfplumber\n",
|
||||||
"import json\n",
|
"name = 'file/01730823-邵希强.pdf'\n",
|
||||||
"import re\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"file = \"file/1_中石化北海炼化2020年团体体检报告.pdf\"\n",
|
"pdf = pdfplumber.open(name)\n",
|
||||||
"tables = camelot.read_pdf(file, pages='3',flavor='stream')\n",
|
"tables =pdf.pages[1].extract_tables()\n",
|
||||||
"# 2.导出pdf所有的表格为csv文件\n",
|
"df1 = tables\n",
|
||||||
"tables.export('foo.json', f='json')\n",
|
"for item in df1:\n",
|
||||||
"print('ok!')"
|
" print(item)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1286,6 +1355,87 @@
|
|||||||
"id": "04dd6436-8374-4096-a2a3-d79f4d93a360",
|
"id": "04dd6436-8374-4096-a2a3-d79f4d93a360",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import pdfplumber\n",
|
||||||
|
"name = 'file/03499391-宋文路.pdf'\n",
|
||||||
|
"pdf = pdfplumber.open(name)\n",
|
||||||
|
"text = pdf.pages[1].extract_text()#######页码从0开始计数\n",
|
||||||
|
"#print(text)\n",
|
||||||
|
"list1 = text.split('\\n')\n",
|
||||||
|
"print(list1)\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" if '测试标准 国民体质测定标准' in item:\n",
|
||||||
|
" list_min = list1.index(item)\n",
|
||||||
|
" if '请注意:以上测试项目' in item:\n",
|
||||||
|
" list_max = list1.index(item)\n",
|
||||||
|
"print(list_min,list_max)\n",
|
||||||
|
"for i in range(list_min+1,list_max):\n",
|
||||||
|
" print(list1[i].split(' ')[0])\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "ac034bf9-cba9-4a72-87ba-d77721cc7097",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import pdfplumber\n",
|
||||||
|
"name = 'file/03499391-宋文路.pdf'\n",
|
||||||
|
"pdf = pdfplumber.open(name)\n",
|
||||||
|
"text = pdf.pages[1].extract_text()#######页码从0开始计数\n",
|
||||||
|
"#print(text)\n",
|
||||||
|
"list1 = text.split('\\n')\n",
|
||||||
|
"print(list1)\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" if '感谢您完成测试' in item:\n",
|
||||||
|
" i = list1.index(item)\n",
|
||||||
|
" ss = ''.join(list1[i:])\n",
|
||||||
|
" print(ss)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "26623725-92da-48d9-a476-78a1befd06ef",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 合并PDF文件"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "9b37b17e-66d3-4acc-8edb-760ea17123b4",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-17T11:00:13.781489Z",
|
||||||
|
"iopub.status.busy": "2026-01-17T11:00:13.780803Z",
|
||||||
|
"iopub.status.idle": "2026-01-17T11:00:14.805023Z",
|
||||||
|
"shell.execute_reply": "2026-01-17T11:00:14.804489Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-17T11:00:13.781426Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from pypdf import PdfWriter\n",
|
||||||
|
"import glob\n",
|
||||||
|
"\n",
|
||||||
|
"fi_path = 'file/2025/'\n",
|
||||||
|
"fls = glob.glob(f'{fi_path}*.pdf')\n",
|
||||||
|
"fls.sort()\n",
|
||||||
|
"merger = PdfWriter()\n",
|
||||||
|
"for pdf in fls:\n",
|
||||||
|
" merger.append(pdf)\n",
|
||||||
|
"merger.write(\"file/2025年总账.pdf\")\n",
|
||||||
|
"merger.close()\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6d5c9dd3-bd09-49b3-8a22-07bb4440aace",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1305,7 +1455,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.8.10"
|
"version": "3.12.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
+14
-14
@@ -2388,15 +2388,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 18,
|
"execution_count": 1,
|
||||||
"id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19",
|
"id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-12-22T11:04:03.470806Z",
|
"iopub.execute_input": "2026-01-22T14:01:06.244749Z",
|
||||||
"iopub.status.busy": "2025-12-22T11:04:03.470172Z",
|
"iopub.status.busy": "2026-01-22T14:01:06.243759Z",
|
||||||
"iopub.status.idle": "2025-12-22T11:04:03.479616Z",
|
"iopub.status.idle": "2026-01-22T14:01:06.255504Z",
|
||||||
"shell.execute_reply": "2025-12-22T11:04:03.479011Z",
|
"shell.execute_reply": "2026-01-22T14:01:06.254604Z",
|
||||||
"shell.execute_reply.started": "2025-12-22T11:04:03.470775Z"
|
"shell.execute_reply.started": "2026-01-22T14:01:06.244689Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -2750,15 +2750,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 19,
|
"execution_count": 2,
|
||||||
"id": "9ecd3ad8-c8af-4f3e-90e5-1618fea905a4",
|
"id": "9ecd3ad8-c8af-4f3e-90e5-1618fea905a4",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-12-22T11:04:25.639587Z",
|
"iopub.execute_input": "2026-01-22T14:01:37.481771Z",
|
||||||
"iopub.status.busy": "2025-12-22T11:04:25.638549Z",
|
"iopub.status.busy": "2026-01-22T14:01:37.481188Z",
|
||||||
"iopub.status.idle": "2025-12-22T11:04:25.677688Z",
|
"iopub.status.idle": "2026-01-22T14:01:37.700702Z",
|
||||||
"shell.execute_reply": "2025-12-22T11:04:25.677118Z",
|
"shell.execute_reply": "2026-01-22T14:01:37.700220Z",
|
||||||
"shell.execute_reply.started": "2025-12-22T11:04:25.639534Z"
|
"shell.execute_reply.started": "2026-01-22T14:01:37.481723Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -2766,7 +2766,7 @@
|
|||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"\n",
|
"\n",
|
||||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||||
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
|
"filename = 'data/result_中心健康检测人员.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"data_list = []\n",
|
"data_list = []\n",
|
||||||
@@ -2848,7 +2848,7 @@
|
|||||||
" list6.append('')\n",
|
" list6.append('')\n",
|
||||||
" i+=1\n",
|
" i+=1\n",
|
||||||
" data_list.append(list6)\n",
|
" data_list.append(list6)\n",
|
||||||
"filename = 'data/新疆油田乒乓球高阶培训班.xlsx'\n",
|
"filename = 'data/中心健康检测人员(20260122).xlsx'\n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '身高', '体重', 'bmi', '肺活量', '得分', '握力', '得分', '坐位体前屈', '得分', '纵跳', '得分', '俯卧撑', '得分', '单脚站立', '得分', '选择反应时', '得分', '台阶指数', '得分', '一分钟仰卧起坐', '得分', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀', '成就感', '愉快心理', '放松程度', '压力应对', '体力充沛', '情感充沛度', '颈椎', '胸椎', '腰椎', '骶尾椎']\n",
|
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '身高', '体重', 'bmi', '肺活量', '得分', '握力', '得分', '坐位体前屈', '得分', '纵跳', '得分', '俯卧撑', '得分', '单脚站立', '得分', '选择反应时', '得分', '台阶指数', '得分', '一分钟仰卧起坐', '得分', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀', '成就感', '愉快心理', '放松程度', '压力应对', '体力充沛', '情感充沛度', '颈椎', '胸椎', '腰椎', '骶尾椎']\n",
|
||||||
|
|||||||
+142
-8
@@ -2228,15 +2228,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 16,
|
"execution_count": 25,
|
||||||
"id": "865ece6f-2d6f-4ae8-a59d-81e2a4bfbbc3",
|
"id": "865ece6f-2d6f-4ae8-a59d-81e2a4bfbbc3",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-12-23T11:34:51.869483Z",
|
"iopub.execute_input": "2025-12-24T02:02:10.197143Z",
|
||||||
"iopub.status.busy": "2025-12-23T11:34:51.868754Z",
|
"iopub.status.busy": "2025-12-24T02:02:10.196863Z",
|
||||||
"iopub.status.idle": "2025-12-23T11:34:52.535335Z",
|
"iopub.status.idle": "2025-12-24T02:02:11.056844Z",
|
||||||
"shell.execute_reply": "2025-12-23T11:34:52.534820Z",
|
"shell.execute_reply": "2025-12-24T02:02:11.056232Z",
|
||||||
"shell.execute_reply.started": "2025-12-23T11:34:51.869418Z"
|
"shell.execute_reply.started": "2025-12-24T02:02:10.197116Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -2255,7 +2255,68 @@
|
|||||||
"赵敏 13977996075\n",
|
"赵敏 13977996075\n",
|
||||||
"张健 15278902286\n",
|
"张健 15278902286\n",
|
||||||
"王勇 13397798753\n",
|
"王勇 13397798753\n",
|
||||||
"兰俊 13000000400\n"
|
"兰俊 13000000400\n",
|
||||||
|
"2204240005 陈萍 None 13000000021 1963-06-01\n",
|
||||||
|
"2209150130 李晗 18277999575 18207799575 1975-01-09\n",
|
||||||
|
"2209150132 朱康利 None 13000000012 1963-06-01\n",
|
||||||
|
"2209150143 赵亮 18507792069 15389017737 1975-01-08\n",
|
||||||
|
"2209150153 邓洪 18977937260 13977933085 1974-06-05\n",
|
||||||
|
"2209150156 熊泽 18877932561 15151989689 1997-12-01\n",
|
||||||
|
"2209150179 张伟 None 18577900517 1984-10-16\n",
|
||||||
|
"2209150179 张伟 None 18419216343 1996-04-01\n",
|
||||||
|
"2209150180 陈维婧 19377997709 18862762501 1995-08-29\n",
|
||||||
|
"2209150194 梁宇谦 18278053305 17878979398 1998-02-05\n",
|
||||||
|
"2209150200 蔡珍花 None 13000000010 1972-06-01\n",
|
||||||
|
"2209150201 谭海燕 None 13000000011 1973-06-01\n",
|
||||||
|
"2209150236 潘永远 None 13000000009 1962-06-01\n",
|
||||||
|
"2209150249 崔庆鹏 None 16604175267 1996-06-01\n",
|
||||||
|
"2209150315 姜美彤 None 13000000007 1995-06-01\n",
|
||||||
|
"2209150389 彭赫 15930485276 15930485275 1995-10-08\n",
|
||||||
|
"2209150428 默鑫晔 15031137901 13398691539 1999-04-30\n",
|
||||||
|
"2209150432 翟东泽 18779200734 18777920734 1990-10-28\n",
|
||||||
|
"2209150435 汪浩 13006992644 15207705743 1989-04-28\n",
|
||||||
|
"2209150436 黄仁进 13807799565 13977968289 1974-01-17\n",
|
||||||
|
"2209150448 吴海炫 17368152039 18777536133 1999-07-24\n",
|
||||||
|
"2209150460 王振宇 17707790123 18277918788 1981-04-08\n",
|
||||||
|
"2209150479 刘明昆 13707795145 13707795415 1992-04-19\n",
|
||||||
|
"2209150519 黄镇云 18269069766 18269069776 1996-11-25\n",
|
||||||
|
"2209150521 高鹏 15777982048 18730137202 1997-07-03\n",
|
||||||
|
"2209150539 李志良 18634152886 15833247754 1996-11-22\n",
|
||||||
|
"2209150595 沈鹏 None 13572866784 1973-07-12\n",
|
||||||
|
"2209150595 沈鹏 None 13877945246 1976-08-15\n",
|
||||||
|
"2209150597 邹赣荣 17707796656 13907791227 1972-11-16\n",
|
||||||
|
"2209150605 陈伟 None 13977973125 1968-07-01\n",
|
||||||
|
"2209150605 陈伟 None 13977908579 1970-02-19\n",
|
||||||
|
"2209150614 周小林 18077967288 18278950265 1966-07-30\n",
|
||||||
|
"2209150640 蔡耐寒 None 18377975557 1989-08-27\n",
|
||||||
|
"2209150640 蔡耐寒 None 18377975557 1989-08-27\n",
|
||||||
|
"2209150672 李辉 None 13878955359 1976-02-16\n",
|
||||||
|
"2209150672 李辉 None 18278953177 1969-05-31\n",
|
||||||
|
"2209150698 刘涛 None 18907799258 1981-08-18\n",
|
||||||
|
"2209150698 刘涛 None 18066959139 1971-10-24\n",
|
||||||
|
"2209150709 温静 1387795052 13877951052 1977-06-04\n",
|
||||||
|
"2209150718 张健 None 13307795732 1988-12-27\n",
|
||||||
|
"2209150718 张健 None 15278902286 1976-12-23\n",
|
||||||
|
"2209150746 王依然 None 18977944546 1989-01-26\n",
|
||||||
|
"2209150751 谭志坚 None 13000000003 1972-06-01\n",
|
||||||
|
"2209150752 冯剑秋 None 13000000004 1972-06-01\n",
|
||||||
|
"2209150753 龙起燕 None 13000000005 1972-06-01\n",
|
||||||
|
"2209150758 王玮 18077961012 18877951012 1993-10-12\n",
|
||||||
|
"2209190122 黄洁 18907795998 18277919889 1973-01-30\n",
|
||||||
|
"2209190131 王刚 15224535346 15224535345 1978-04-17\n",
|
||||||
|
"2209190146 苏强辉 None 13907791096 1967-06-01\n",
|
||||||
|
"2209190188 王广乾 17677093562 18077966362 1985-03-11\n",
|
||||||
|
"2209190192 廖祁军 18907790417 18907790418 1970-04-01\n",
|
||||||
|
"2209190205 梁艳玲 None 13000000019 1976-06-01\n",
|
||||||
|
"2209190220 宋庆群 None 15063050669 1985-06-01\n",
|
||||||
|
"2209190228 张伟 17880496342 18577900517 1984-10-16\n",
|
||||||
|
"2209190228 张伟 17880496342 18419216343 1996-04-01\n",
|
||||||
|
"2209190234 陈闯 None 13000000016 1967-06-01\n",
|
||||||
|
"2209190235 杜晓卉 None 13000000017 1972-06-01\n",
|
||||||
|
"2209190250 马玲 None 13000000015 1967-06-01\n",
|
||||||
|
"2209190262 杜海惠 None 13000000014 1964-06-01\n",
|
||||||
|
"2210260010 洪元大 None 13000000002 1962-06-01\n",
|
||||||
|
"2210260010 洪元大 None 13000000002 1962-06-01\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -2287,7 +2348,7 @@
|
|||||||
"wb = openpyxl.load_workbook('data/北海炼化职业体检数据-11.23.xlsx')\n",
|
"wb = openpyxl.load_workbook('data/北海炼化职业体检数据-11.23.xlsx')\n",
|
||||||
"#sheet = wb.active\n",
|
"#sheet = wb.active\n",
|
||||||
"# sheets = wb.sheetnames\n",
|
"# sheets = wb.sheetnames\n",
|
||||||
"sheet = wb['2024']\n",
|
"sheet = wb['2022']\n",
|
||||||
"\n",
|
"\n",
|
||||||
"list2 = []\n",
|
"list2 = []\n",
|
||||||
"for n in range(2, sheet.max_row+1):\n",
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
@@ -2306,6 +2367,79 @@
|
|||||||
" print(code,v['name'],phone,v['phone'],v['birth'])"
|
" print(code,v['name'],phone,v['phone'],v['birth'])"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 24,
|
||||||
|
"id": "fb8d59d5-6a1f-45c5-ba82-2620f1cff5ad",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-12-24T02:02:02.690630Z",
|
||||||
|
"iopub.status.busy": "2025-12-24T02:02:02.690140Z",
|
||||||
|
"iopub.status.idle": "2025-12-24T02:02:03.276258Z",
|
||||||
|
"shell.execute_reply": "2025-12-24T02:02:03.275729Z",
|
||||||
|
"shell.execute_reply.started": "2025-12-24T02:02:02.690585Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"995\n",
|
||||||
|
"张伟 18419216343\n",
|
||||||
|
"李辉 18278953177\n",
|
||||||
|
"刘涛 18066959139\n",
|
||||||
|
"陈伟 13977908579\n",
|
||||||
|
"沈鹏 13877945246\n",
|
||||||
|
"王勇 13006999505\n",
|
||||||
|
"李华 13949350582\n",
|
||||||
|
"赵敏 13977996075\n",
|
||||||
|
"张健 15278902286\n",
|
||||||
|
"王勇 13397798753\n",
|
||||||
|
"兰俊 13000000400\n",
|
||||||
|
"涂丽\n",
|
||||||
|
"候海霞\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"title = []\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/tb_user.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"for item in dict1:\n",
|
||||||
|
" id = item['id']\n",
|
||||||
|
" dict2.setdefault(id,{})\n",
|
||||||
|
" dict2[id] ['name']= item['username']\n",
|
||||||
|
" dict2[id] ['phone']= item['mobile']\n",
|
||||||
|
" dict2[id] ['unit']= item['dept']\n",
|
||||||
|
" dict2[id] ['birth']= item['birthday']\n",
|
||||||
|
"print(len(dict2))\n",
|
||||||
|
"for k,v in dict2.items():\n",
|
||||||
|
" if v['name'] in list1:\n",
|
||||||
|
" print(v['name'],v['phone'])\n",
|
||||||
|
" else:\n",
|
||||||
|
" list1.append(v['name'])\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/北海炼化职业体检数据-11.23.xlsx')\n",
|
||||||
|
"#sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"sheet = wb['2022']\n",
|
||||||
|
"\n",
|
||||||
|
"list2 = []\n",
|
||||||
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
|
" name = sheet.cell(n, 2).value\n",
|
||||||
|
" if name not in (list1):\n",
|
||||||
|
" print(name)\n",
|
||||||
|
" "
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
|
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
|
||||||
|
|||||||
+54
-427
@@ -3,9 +3,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "a3a2e21f-e62e-465b-818d-8acea289434f",
|
"id": "a3a2e21f-e62e-465b-818d-8acea289434f",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"jp-MarkdownHeadingCollapsed": true
|
|
||||||
},
|
|
||||||
"source": [
|
"source": [
|
||||||
"# 体质检测"
|
"# 体质检测"
|
||||||
]
|
]
|
||||||
@@ -1018,26 +1016,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 28,
|
"execution_count": null,
|
||||||
"id": "7261e146-03f5-4943-8a3a-479d0e4a025d",
|
"id": "7261e146-03f5-4943-8a3a-479d0e4a025d",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2025-12-09T09:50:57.787016Z",
|
|
||||||
"iopub.status.busy": "2025-12-09T09:50:57.786321Z",
|
|
||||||
"iopub.status.idle": "2025-12-09T09:50:57.827675Z",
|
|
||||||
"shell.execute_reply": "2025-12-09T09:50:57.827125Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-09T09:50:57.786958Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"204 ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import csv\n",
|
"import csv\n",
|
||||||
@@ -1051,7 +1033,7 @@
|
|||||||
" \n",
|
" \n",
|
||||||
"dict1 = {}\n",
|
"dict1 = {}\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"filename = 'data/sql_20251209.csv'\n",
|
"filename = 'data/sql_20260113.csv'\n",
|
||||||
"with open(filename,'r',newline='') as csv_file:\n",
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
" header = next(fl) \n",
|
" header = next(fl) \n",
|
||||||
@@ -1090,7 +1072,7 @@
|
|||||||
" dict1[code]['waist'] = dict2['waist']\n",
|
" dict1[code]['waist'] = dict2['waist']\n",
|
||||||
" dict1[code]['hip'] = dict2['hip']\n",
|
" dict1[code]['hip'] = dict2['hip']\n",
|
||||||
" dict1[code]['tcm'] = tcm\n",
|
" dict1[code]['tcm'] = tcm\n",
|
||||||
"filename = 'data/survey_宁夏能化高危风险干预人员.json'\n",
|
"filename = 'data/survey_宁夏能化高危风险干预人员(20260113).json'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||||
@@ -1099,26 +1081,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 25,
|
"execution_count": null,
|
||||||
"id": "02d82c2a-2319-4c0b-be58-0a1b107fdc35",
|
"id": "02d82c2a-2319-4c0b-be58-0a1b107fdc35",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2025-12-22T07:38:35.217789Z",
|
|
||||||
"iopub.status.busy": "2025-12-22T07:38:35.217210Z",
|
|
||||||
"iopub.status.idle": "2025-12-22T07:38:35.238667Z",
|
|
||||||
"shell.execute_reply": "2025-12-22T07:38:35.238165Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-22T07:38:35.217760Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"111 ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import csv\n",
|
"import csv\n",
|
||||||
@@ -1132,7 +1098,7 @@
|
|||||||
" \n",
|
" \n",
|
||||||
"dict1 = {}\n",
|
"dict1 = {}\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"filename = 'data/sql_20251222.csv'\n",
|
"filename = 'data/sql_20260113.csv'\n",
|
||||||
"with open(filename,'r',newline='') as csv_file:\n",
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
" header = next(fl) \n",
|
" header = next(fl) \n",
|
||||||
@@ -1163,7 +1129,7 @@
|
|||||||
" dict1[code]['tcm'] = tcm \n",
|
" dict1[code]['tcm'] = tcm \n",
|
||||||
" \n",
|
" \n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/survey_宁夏能化高危风险干预人员(202512).json'\n",
|
"filename = 'data/survey_宁夏能化高危风险干预人员(20601).json'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||||
@@ -1180,17 +1146,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 26,
|
"execution_count": null,
|
||||||
"id": "34cb26d7-cd7b-4ad5-bb7b-71cfcce16c24",
|
"id": "34cb26d7-cd7b-4ad5-bb7b-71cfcce16c24",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2025-12-22T07:39:25.697010Z",
|
|
||||||
"iopub.status.busy": "2025-12-22T07:39:25.696512Z",
|
|
||||||
"iopub.status.idle": "2025-12-22T07:39:25.707108Z",
|
|
||||||
"shell.execute_reply": "2025-12-22T07:39:25.706358Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-22T07:39:25.696961Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -1254,23 +1212,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 27,
|
"execution_count": null,
|
||||||
"id": "d78c0f3f-cd1a-4c6c-9f5b-b1b874a95fe3",
|
"id": "d78c0f3f-cd1a-4c6c-9f5b-b1b874a95fe3",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2025-12-22T07:40:30.226248Z",
|
|
||||||
"iopub.status.busy": "2025-12-22T07:40:30.225697Z",
|
|
||||||
"iopub.status.idle": "2025-12-22T07:40:30.260291Z",
|
|
||||||
"shell.execute_reply": "2025-12-22T07:40:30.259853Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-22T07:40:30.226194Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/survey_宁夏能化高危风险干预人员(202512).json'\n",
|
"filename = 'data/survey_宁夏能化高危风险干预人员(20601).json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"data_list = []\n",
|
"data_list = []\n",
|
||||||
@@ -1308,7 +1258,7 @@
|
|||||||
" i+=1\n",
|
" i+=1\n",
|
||||||
" \n",
|
" \n",
|
||||||
" data_list.append(list6)\n",
|
" data_list.append(list6)\n",
|
||||||
"filename = 'data/宁夏能化高危风险干预人员体质问卷明细表(20251222).xlsx'\n",
|
"filename = 'data/宁夏能化高危风险干预人员体质问卷明细表(20260113).xlsx'\n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '腰围', '臀围', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀']\n",
|
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '腰围', '臀围', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀']\n",
|
||||||
@@ -1383,15 +1333,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 15,
|
"execution_count": 6,
|
||||||
"id": "22be8f39-afbb-448a-8ae6-c825c7d38757",
|
"id": "22be8f39-afbb-448a-8ae6-c825c7d38757",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-12-22T03:43:54.245786Z",
|
"iopub.execute_input": "2026-01-21T07:58:19.506695Z",
|
||||||
"iopub.status.busy": "2025-12-22T03:43:54.245059Z",
|
"iopub.status.busy": "2026-01-21T07:58:19.506209Z",
|
||||||
"iopub.status.idle": "2025-12-22T03:43:54.418251Z",
|
"iopub.status.idle": "2026-01-21T07:58:19.652782Z",
|
||||||
"shell.execute_reply": "2025-12-22T03:43:54.417770Z",
|
"shell.execute_reply": "2026-01-21T07:58:19.652243Z",
|
||||||
"shell.execute_reply.started": "2025-12-22T03:43:54.245721Z"
|
"shell.execute_reply.started": "2026-01-21T07:58:19.506650Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -1401,8 +1351,9 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"title = []\n",
|
"title = []\n",
|
||||||
|
"riqi = '2026-01-21'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/surveys_records_2025-12-22.json'\n",
|
"filename = f'data/surveys_records_{riqi}.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl)\n",
|
" dict1 = json.load(fl)\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
@@ -1427,7 +1378,7 @@
|
|||||||
" \n",
|
" \n",
|
||||||
" list1.append(list2)\n",
|
" list1.append(list2)\n",
|
||||||
"all_title = ['id', 'date_created','name', 'gender', 'birth', 'code', 'unit', 'height', 'weight', 'next_weight', 'waist', 'hip', 'level4', 'level3', 'level2', 'recipe', 'level1', 'last_level4', 'last_level3', 'last_level2', 'last_level1', 'last_recipe', 'last_lose', 'last_sport', 'sport_type', 'sport_duration', 'last_sport_time', 'last_lose-Comment', 'last_recipe-Comment', 'last_lose_weight', 'last_sport-Comment', 'sport_type-Comment']\n",
|
"all_title = ['id', 'date_created','name', 'gender', 'birth', 'code', 'unit', 'height', 'weight', 'next_weight', 'waist', 'hip', 'level4', 'level3', 'level2', 'recipe', 'level1', 'last_level4', 'last_level3', 'last_level2', 'last_level1', 'last_recipe', 'last_lose', 'last_sport', 'sport_type', 'sport_duration', 'last_sport_time', 'last_lose-Comment', 'last_recipe-Comment', 'last_lose_weight', 'last_sport-Comment', 'sport_type-Comment']\n",
|
||||||
"filename = 'data/宁夏能化干预人员问卷(20251222).xlsx'\n",
|
"filename = f'data/宁夏能化干预人员问卷({riqi}).xlsx'\n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"sheet.append(all_title)\n",
|
"sheet.append(all_title)\n",
|
||||||
@@ -1463,15 +1414,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 16,
|
"execution_count": 7,
|
||||||
"id": "91c53866-3725-4ceb-b0eb-23fb14e20561",
|
"id": "91c53866-3725-4ceb-b0eb-23fb14e20561",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-12-22T03:44:05.908310Z",
|
"iopub.execute_input": "2026-01-21T07:58:22.208413Z",
|
||||||
"iopub.status.busy": "2025-12-22T03:44:05.907768Z",
|
"iopub.status.busy": "2026-01-21T07:58:22.208109Z",
|
||||||
"iopub.status.idle": "2025-12-22T03:44:06.062310Z",
|
"iopub.status.idle": "2026-01-21T07:58:22.348694Z",
|
||||||
"shell.execute_reply": "2025-12-22T03:44:06.061610Z",
|
"shell.execute_reply": "2026-01-21T07:58:22.348158Z",
|
||||||
"shell.execute_reply.started": "2025-12-22T03:44:05.908261Z"
|
"shell.execute_reply.started": "2026-01-21T07:58:22.208379Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -1479,26 +1430,9 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"('汪晖', '男', '销售中心', '1971-02-01', '02019646', 1)\n",
|
"('马伟', '男', '电气仪表中心', '1997-02-01', '03442537', 1)\n",
|
||||||
"('马燕金', '男', '销售中心', '1983-04-01', '02018528', 1)\n",
|
"('应二超', '男', '公用工程运行部', '1989-02-01', '02020323', 1)\n",
|
||||||
"('孙皓', '男', '销售中心', '1990-10-01', '02019111', 1)\n",
|
"2\n"
|
||||||
"('李润良', '男', '环保建材运行部', '1992-06-01', '03427471', 1)\n",
|
|
||||||
"('王春光', '男', '环保建材运行部', '1969-12-01', '02020528', 1)\n",
|
|
||||||
"('户利平', '男', '环保建材运行部', '1969-08-01', '02020512', 1)\n",
|
|
||||||
"('马婉婷', '女', '公用工程运行部', '2001-11-01', '03561578', 1)\n",
|
|
||||||
"('储方伟', '男', '环保建材运行部', '1976-01-01', '02020483', 1)\n",
|
|
||||||
"('马斯勇', '男', '环保建材运行部', '1987-08-01', '02020525', 1)\n",
|
|
||||||
"('康磊', '男', '公用工程运行部', '1987-07-01', '02020289', 1)\n",
|
|
||||||
"('王涛', '男', '环保建材运行部', '1982-07-01', '00000521', 1)\n",
|
|
||||||
"('杨德忠', '男', '公用工程运行部', '1972-11-01', '02020306', 1)\n",
|
|
||||||
"('杨思国', '男', '电气仪表中心', '1981-04-01', '02018877', 1)\n",
|
|
||||||
"('党金广', '男', '电气仪表中心', '1987-08-01', '02018839', 1)\n",
|
|
||||||
"('张锋', '男', '电气仪表中心', '1971-05-01', '02020003', 1)\n",
|
|
||||||
"('张磊', '男', '电气仪表中心', '1989-12-01', '02018949', 1)\n",
|
|
||||||
"('秦国振', '男', '电气仪表中心', '1997-07-01', '03462294', 1)\n",
|
|
||||||
"('陈龙', '男', '电气仪表中心', '1981-05-01', '02018914', 1)\n",
|
|
||||||
"('朱岳峰', '男', '电气仪表中心', '1988-02-01', '02018865', 1)\n",
|
|
||||||
"19\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1514,7 +1448,7 @@
|
|||||||
" password=\"songyi\"\n",
|
" password=\"songyi\"\n",
|
||||||
")\n",
|
")\n",
|
||||||
"cur = conn.cursor()\n",
|
"cur = conn.cursor()\n",
|
||||||
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251222).xlsx',data_only=True)\n",
|
"wb = openpyxl.load_workbook(f'data/宁夏能化干预人员问卷({riqi}).xlsx',data_only=True)\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"# sheets = wb.sheetnames\n",
|
"# sheets = wb.sheetnames\n",
|
||||||
"org_id = 1\n",
|
"org_id = 1\n",
|
||||||
@@ -1648,15 +1582,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": 8,
|
||||||
"id": "b7133988-213c-4b52-8d6b-17b56b8ea310",
|
"id": "b7133988-213c-4b52-8d6b-17b56b8ea310",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-12-22T03:49:22.646173Z",
|
"iopub.execute_input": "2026-01-21T07:58:41.923296Z",
|
||||||
"iopub.status.busy": "2025-12-22T03:49:22.645514Z",
|
"iopub.status.busy": "2026-01-21T07:58:41.922694Z",
|
||||||
"iopub.status.idle": "2025-12-22T03:49:22.842656Z",
|
"iopub.status.idle": "2026-01-21T07:58:42.106793Z",
|
||||||
"shell.execute_reply": "2025-12-22T03:49:22.842110Z",
|
"shell.execute_reply": "2026-01-21T07:58:42.106233Z",
|
||||||
"shell.execute_reply.started": "2025-12-22T03:49:22.646116Z"
|
"shell.execute_reply.started": "2026-01-21T07:58:41.923241Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -1664,313 +1598,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"02019646\n",
|
"260 ok\n"
|
||||||
"2018434\n",
|
|
||||||
"02018586\n",
|
|
||||||
"02018444\n",
|
|
||||||
"02020443\n",
|
|
||||||
"02020415\n",
|
|
||||||
"02018446\n",
|
|
||||||
"2018447\n",
|
|
||||||
"03533284\n",
|
|
||||||
"02020243\n",
|
|
||||||
"02019374\n",
|
|
||||||
"02020238\n",
|
|
||||||
"02019952\n",
|
|
||||||
"03497967\n",
|
|
||||||
"02018709\n",
|
|
||||||
"02019342\n",
|
|
||||||
"02019620\n",
|
|
||||||
"02020203\n",
|
|
||||||
"02018528\n",
|
|
||||||
"02019111\n",
|
|
||||||
"02018482\n",
|
|
||||||
"02018481\n",
|
|
||||||
"02018628\n",
|
|
||||||
"02018498\n",
|
|
||||||
"02018499\n",
|
|
||||||
"964089\n",
|
|
||||||
"0214545\n",
|
|
||||||
"02020481\n",
|
|
||||||
"2018609\n",
|
|
||||||
"01348929\n",
|
|
||||||
"02020526\n",
|
|
||||||
"03427471\n",
|
|
||||||
"02020196\n",
|
|
||||||
"02020528\n",
|
|
||||||
"2019094\n",
|
|
||||||
"02020512\n",
|
|
||||||
"02020476\n",
|
|
||||||
"03561578\n",
|
|
||||||
"0003533364\n",
|
|
||||||
"02019294\n",
|
|
||||||
"02020483\n",
|
|
||||||
"02020527\n",
|
|
||||||
"02020467\n",
|
|
||||||
"02020296\n",
|
|
||||||
"02020525\n",
|
|
||||||
"02020289\n",
|
|
||||||
"03434760\n",
|
|
||||||
"02018435\n",
|
|
||||||
"2019094\n",
|
|
||||||
"02019688\n",
|
|
||||||
"02019688\n",
|
|
||||||
"03561564\n",
|
|
||||||
"02020346\n",
|
|
||||||
"02020458\n",
|
|
||||||
"00000521\n",
|
|
||||||
"02020306\n",
|
|
||||||
"02019655\n",
|
|
||||||
"02020189\n",
|
|
||||||
"02019787\n",
|
|
||||||
"02019787\n",
|
|
||||||
"02018611\n",
|
|
||||||
"02018566\n",
|
|
||||||
"02018645\n",
|
|
||||||
"02019485\n",
|
|
||||||
"02020127\n",
|
|
||||||
"02019054\n",
|
|
||||||
"2019006\n",
|
|
||||||
"028415\n",
|
|
||||||
"03462271\n",
|
|
||||||
"02028323\n",
|
|
||||||
"02020492\n",
|
|
||||||
"02018794\n",
|
|
||||||
"02018877\n",
|
|
||||||
"02018926\n",
|
|
||||||
"02018809\n",
|
|
||||||
"02018938\n",
|
|
||||||
"02020083\n",
|
|
||||||
"02018839\n",
|
|
||||||
"2018985\n",
|
|
||||||
"02019866\n",
|
|
||||||
"02018793\n",
|
|
||||||
"03428863\n",
|
|
||||||
"02019017\n",
|
|
||||||
"02018981\n",
|
|
||||||
"02020003\n",
|
|
||||||
"03462285\n",
|
|
||||||
"02018626\n",
|
|
||||||
"02018604\n",
|
|
||||||
"02018892\n",
|
|
||||||
"02018827\n",
|
|
||||||
"02018949\n",
|
|
||||||
"02019599\n",
|
|
||||||
"02019622\n",
|
|
||||||
"02018575\n",
|
|
||||||
"2018438\n",
|
|
||||||
"02019613\n",
|
|
||||||
"03363370\n",
|
|
||||||
"01702447\n",
|
|
||||||
"020186\n",
|
|
||||||
"02018709\n",
|
|
||||||
"03497967\n",
|
|
||||||
"0201968\n",
|
|
||||||
"02019641\n",
|
|
||||||
"02018709\n",
|
|
||||||
"02019697\n",
|
|
||||||
"02019021\n",
|
|
||||||
"0435\n",
|
|
||||||
"02018685\n",
|
|
||||||
"02018772\n",
|
|
||||||
"02019620\n",
|
|
||||||
"03497960\n",
|
|
||||||
"02019888\n",
|
|
||||||
"02019682\n",
|
|
||||||
"03391642\n",
|
|
||||||
"03462294\n",
|
|
||||||
"02018914\n",
|
|
||||||
"2019961\n",
|
|
||||||
"02018859\n",
|
|
||||||
"02019377\n",
|
|
||||||
"02017961\n",
|
|
||||||
"02018607\n",
|
|
||||||
"02018865\n",
|
|
||||||
"02020277\n",
|
|
||||||
"02020251\n",
|
|
||||||
"02020321\n",
|
|
||||||
"03391661\n",
|
|
||||||
"02020276\n",
|
|
||||||
"02019062\n",
|
|
||||||
"02019887\n",
|
|
||||||
"03148213\n",
|
|
||||||
"2019822\n",
|
|
||||||
"02019840\n",
|
|
||||||
"02019790\n",
|
|
||||||
"02019819\n",
|
|
||||||
"02019754\n",
|
|
||||||
"03437945\n",
|
|
||||||
"02019749\n",
|
|
||||||
"02019111\n",
|
|
||||||
"03418292\n",
|
|
||||||
"02019764\n",
|
|
||||||
"02019744\n",
|
|
||||||
"02019734\n",
|
|
||||||
"02019374\n",
|
|
||||||
"02019778\n",
|
|
||||||
"02019788\n",
|
|
||||||
"02019725\n",
|
|
||||||
"02017961\n",
|
|
||||||
"02019751\n",
|
|
||||||
"02020282\n",
|
|
||||||
"02019856\n",
|
|
||||||
"02019832\n",
|
|
||||||
"02019848\n",
|
|
||||||
"03437965\n",
|
|
||||||
"02019954\n",
|
|
||||||
"02020052\n",
|
|
||||||
"02019820\n",
|
|
||||||
"02019893\n",
|
|
||||||
"02019752\n",
|
|
||||||
"02019784\n",
|
|
||||||
"02020343\n",
|
|
||||||
"02019810\n",
|
|
||||||
"2019735\n",
|
|
||||||
"02019023\n",
|
|
||||||
"02020327\n",
|
|
||||||
"02019852\n",
|
|
||||||
"02018538\n",
|
|
||||||
"02018977\n",
|
|
||||||
"2018942\n",
|
|
||||||
"02019898\n",
|
|
||||||
"02019794\n",
|
|
||||||
"02019805\n",
|
|
||||||
"02019342\n",
|
|
||||||
"02019895\n",
|
|
||||||
"02019154\n",
|
|
||||||
"02019775\n",
|
|
||||||
"3391687\n",
|
|
||||||
"02019917\n",
|
|
||||||
"02018754\n",
|
|
||||||
"03418302\n",
|
|
||||||
"02019738\n",
|
|
||||||
"03462274\n",
|
|
||||||
"03561561\n",
|
|
||||||
"02019783\n",
|
|
||||||
"02018967\n",
|
|
||||||
"2019324\n",
|
|
||||||
"02019355\n",
|
|
||||||
"02019003\n",
|
|
||||||
"02019377\n",
|
|
||||||
"02019803\n",
|
|
||||||
"02019311\n",
|
|
||||||
"02019346\n",
|
|
||||||
"02019525\n",
|
|
||||||
"02020502\n",
|
|
||||||
"03497957\n",
|
|
||||||
"02020242\n",
|
|
||||||
"02019347\n",
|
|
||||||
"3418215\n",
|
|
||||||
"02019340\n",
|
|
||||||
"02019773\n",
|
|
||||||
"0219181\n",
|
|
||||||
"02019336\n",
|
|
||||||
"02019340\n",
|
|
||||||
"02018999\n",
|
|
||||||
"02019357\n",
|
|
||||||
"02019100\n",
|
|
||||||
"02019430\n",
|
|
||||||
"02019356\n",
|
|
||||||
"03418230\n",
|
|
||||||
"03437952\n",
|
|
||||||
"03437952\n",
|
|
||||||
"02019231\n",
|
|
||||||
"03497937\n",
|
|
||||||
"03497917\n",
|
|
||||||
"02019318\n",
|
|
||||||
"03462262\n",
|
|
||||||
"02019110\n",
|
|
||||||
"2019919\n",
|
|
||||||
"02019382\n",
|
|
||||||
"03497562\n",
|
|
||||||
"02019369\n",
|
|
||||||
"03391686\n",
|
|
||||||
"02019736\n",
|
|
||||||
"02019786\n",
|
|
||||||
"02019411\n",
|
|
||||||
"3391674\n",
|
|
||||||
"02018727\n",
|
|
||||||
"02019035\n",
|
|
||||||
"02019350\n",
|
|
||||||
"02019414\n",
|
|
||||||
"2019353\n",
|
|
||||||
"2019353\n",
|
|
||||||
"2019493\n",
|
|
||||||
"02019903\n",
|
|
||||||
"02019825\n",
|
|
||||||
"02019802\n",
|
|
||||||
"03394941\n",
|
|
||||||
"02020243\n",
|
|
||||||
"2019914\n",
|
|
||||||
"02019164\n",
|
|
||||||
"02019467\n",
|
|
||||||
"03437937\n",
|
|
||||||
"02019366\n",
|
|
||||||
"02019344\n",
|
|
||||||
"2019930\n",
|
|
||||||
"02019910\n",
|
|
||||||
"02019647\n",
|
|
||||||
"02019843\n",
|
|
||||||
"01825596\n",
|
|
||||||
"02019882\n",
|
|
||||||
"03409694\n",
|
|
||||||
"02019391\n",
|
|
||||||
"02019389\n",
|
|
||||||
"02019301\n",
|
|
||||||
"02020005\n",
|
|
||||||
"02019920\n",
|
|
||||||
"02019498\n",
|
|
||||||
"02019373\n",
|
|
||||||
"02019733\n",
|
|
||||||
"2019998\n",
|
|
||||||
"02020000\n",
|
|
||||||
"02019401\n",
|
|
||||||
"02019901\n",
|
|
||||||
"03418242\n",
|
|
||||||
"02019383\n",
|
|
||||||
"02019438\n",
|
|
||||||
"02019871\n",
|
|
||||||
"02019193\n",
|
|
||||||
"02019635\n",
|
|
||||||
"02020203\n",
|
|
||||||
"02019098\n",
|
|
||||||
"02019459\n",
|
|
||||||
"02018996\n",
|
|
||||||
"02019499\n",
|
|
||||||
"02019687\n",
|
|
||||||
"02018674\n",
|
|
||||||
"02019059\n",
|
|
||||||
"02019059\n",
|
|
||||||
"2019845\n",
|
|
||||||
"2018609\n",
|
|
||||||
"02019379\n",
|
|
||||||
"02020006\n",
|
|
||||||
"2019923\n",
|
|
||||||
"02019774\n",
|
|
||||||
"02019068\n",
|
|
||||||
"020294\n",
|
|
||||||
"03403228\n",
|
|
||||||
"3019337\n",
|
|
||||||
"02018711\n",
|
|
||||||
"03462315\n",
|
|
||||||
"02019739\n",
|
|
||||||
"02019278\n",
|
|
||||||
"02019416\n",
|
|
||||||
"2018973\n",
|
|
||||||
"02019256\n",
|
|
||||||
"02019878\n",
|
|
||||||
"02019664\n",
|
|
||||||
"02019404\n",
|
|
||||||
"02019058\n",
|
|
||||||
"02019504\n",
|
|
||||||
"02019361\n",
|
|
||||||
"02019600\n",
|
|
||||||
"02019381\n",
|
|
||||||
"02019248\n",
|
|
||||||
"02019543\n",
|
|
||||||
"02019648\n",
|
|
||||||
"02020260\n",
|
|
||||||
"287 ok\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1978,13 +1606,12 @@
|
|||||||
"import json\n",
|
"import json\n",
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"\n",
|
"\n",
|
||||||
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251222).xlsx',data_only=True)\n",
|
"wb = openpyxl.load_workbook(f'data/宁夏能化干预人员问卷({riqi}).xlsx',data_only=True)\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"# sheets = wb.sheetnames\n",
|
"# sheets = wb.sheetnames\n",
|
||||||
"person = {}\n",
|
"person = {}\n",
|
||||||
"for n in range(2, sheet.max_row+1):\n",
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
" code = str(sheet.cell(n, 6).value)\n",
|
" code = str(sheet.cell(n, 6).value)\n",
|
||||||
" print(code)\n",
|
|
||||||
" person.setdefault(code, {})\n",
|
" person.setdefault(code, {})\n",
|
||||||
" dict1 = {}\n",
|
" dict1 = {}\n",
|
||||||
" dict1['name'] = sheet.cell(n, 3).value\n",
|
" dict1['name'] = sheet.cell(n, 3).value\n",
|
||||||
@@ -2002,7 +1629,7 @@
|
|||||||
" person[code] = dict1\n",
|
" person[code] = dict1\n",
|
||||||
"#print(person)\n",
|
"#print(person)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/surveys_records_2025-12-22.json'\n",
|
"filename = f'data/surveys_records_{riqi}.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl)\n",
|
" dict1 = json.load(fl)\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
@@ -2013,6 +1640,7 @@
|
|||||||
" dict2 = {}\n",
|
" dict2 = {}\n",
|
||||||
" data = json.loads(item['data'])\n",
|
" data = json.loads(item['data'])\n",
|
||||||
" code = data['code']\n",
|
" code = data['code']\n",
|
||||||
|
" #print(code)\n",
|
||||||
" rq = item['date_created'].split()[0]\n",
|
" rq = item['date_created'].split()[0]\n",
|
||||||
" dict2['height'] = str('%.2f' % data['height'])\n",
|
" dict2['height'] = str('%.2f' % data['height'])\n",
|
||||||
" dict2['weight'] = str('%.2f' %data['weight'])\n",
|
" dict2['weight'] = str('%.2f' %data['weight'])\n",
|
||||||
@@ -2060,7 +1688,7 @@
|
|||||||
" dict2['last_lose-Comment'] = data['last_lose-Comment']\n",
|
" dict2['last_lose-Comment'] = data['last_lose-Comment']\n",
|
||||||
" if code in person.keys():\n",
|
" if code in person.keys():\n",
|
||||||
" person[code][rq] = dict2\n",
|
" person[code][rq] = dict2\n",
|
||||||
"filename = 'data/宁夏能化干预人员问卷情况(20251222).json'\n",
|
"filename = f'data/宁夏能化干预人员问卷情况({riqi}).json'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(person, fl, ensure_ascii=False)\n",
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||||
@@ -2078,15 +1706,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 21,
|
"execution_count": 9,
|
||||||
"id": "55b20059-ae36-493e-b0c5-c7e35473efc7",
|
"id": "55b20059-ae36-493e-b0c5-c7e35473efc7",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-12-22T03:49:42.115930Z",
|
"iopub.execute_input": "2026-01-21T07:58:45.779363Z",
|
||||||
"iopub.status.busy": "2025-12-22T03:49:42.114895Z",
|
"iopub.status.busy": "2026-01-21T07:58:45.778644Z",
|
||||||
"iopub.status.idle": "2025-12-22T03:49:43.037249Z",
|
"iopub.status.idle": "2026-01-21T07:58:46.618870Z",
|
||||||
"shell.execute_reply": "2025-12-22T03:49:43.036729Z",
|
"shell.execute_reply": "2026-01-21T07:58:46.618242Z",
|
||||||
"shell.execute_reply.started": "2025-12-22T03:49:42.115872Z"
|
"shell.execute_reply.started": "2026-01-21T07:58:45.779302Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -2105,7 +1733,7 @@
|
|||||||
"cur = conn.cursor()\n",
|
"cur = conn.cursor()\n",
|
||||||
"event_id = 1\n",
|
"event_id = 1\n",
|
||||||
"org_id = 1\n",
|
"org_id = 1\n",
|
||||||
"filename = 'data/宁夏能化干预人员问卷情况(20251222).json'\n",
|
"filename = f'data/宁夏能化干预人员问卷情况({riqi}).json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl)\n",
|
" dict1 = json.load(fl)\n",
|
||||||
"list1 = ['name','sex','birth','unit']\n",
|
"list1 = ['name','sex','birth','unit']\n",
|
||||||
@@ -2139,7 +1767,6 @@
|
|||||||
" data1.append(v[rq]['sport_type'])\n",
|
" data1.append(v[rq]['sport_type'])\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" data1.append('')\n",
|
" data1.append('')\n",
|
||||||
" \n",
|
|
||||||
" if 'sport_duration' in v[rq].keys():\n",
|
" if 'sport_duration' in v[rq].keys():\n",
|
||||||
" data1.append(v[rq]['sport_duration'])\n",
|
" data1.append(v[rq]['sport_duration'])\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
|
|||||||
+477
@@ -0,0 +1,477 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "579527eb-e2aa-4af6-9668-646e0a997d79",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 体测人员导入"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "272aca0e-b70c-46fe-ae58-ad8aaa5b9fa5",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-22T13:27:05.690761Z",
|
||||||
|
"iopub.status.busy": "2026-01-22T13:27:05.690222Z",
|
||||||
|
"iopub.status.idle": "2026-01-22T13:27:05.710714Z",
|
||||||
|
"shell.execute_reply": "2026-01-22T13:27:05.710237Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-22T13:27:05.690707Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"48 ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/中心健康检测人员.xlsx',data_only=True)\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"person = {}\n",
|
||||||
|
"\n",
|
||||||
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
|
" code = int(sheet.cell(n, 1).value)\n",
|
||||||
|
" person.setdefault(code, {})\n",
|
||||||
|
" dict1 = {}\n",
|
||||||
|
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||||||
|
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||||||
|
" \n",
|
||||||
|
" dict1['unit'] = sheet.cell(n, 4).value\n",
|
||||||
|
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0] \n",
|
||||||
|
" person[code] = dict1\n",
|
||||||
|
"filename = 'data/中心健康检测人员.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||||
|
"print(len(person),'ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "2c452983-0914-4508-86d6-2d9d5f966a8c",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成读卡系统文件"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "fde0146f-02e7-4519-9029-5819b2cc1a20",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-21T08:58:28.607660Z",
|
||||||
|
"iopub.status.busy": "2026-01-21T08:58:28.607052Z",
|
||||||
|
"iopub.status.idle": "2026-01-21T08:58:28.617819Z",
|
||||||
|
"shell.execute_reply": "2026-01-21T08:58:28.616724Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-21T08:58:28.607601Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/中心健康检测人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" dict2 = {}\n",
|
||||||
|
" #if dict1['sex'] =='男':\n",
|
||||||
|
" # sex = 1\n",
|
||||||
|
" \n",
|
||||||
|
" dict2 = {'id':k,'name':v['name'],'gender':v['sex'],'birth':v['birth'],'unit':v['unit']}\n",
|
||||||
|
" list1.append(dict2)\n",
|
||||||
|
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
|
||||||
|
"\n",
|
||||||
|
"# 将 json 数据写入文件\n",
|
||||||
|
"with open(\"data/data_中心健康检测人员.json\", \"w\",encoding = 'utf-8') as file:\n",
|
||||||
|
" file.write(json_data) \n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "28875e1d-1c0f-443a-a780-4cbea10a5133",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 获取人员测试成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "32ef3c92-8644-4421-a9dd-8ae901cb2710",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-22T13:30:00.421898Z",
|
||||||
|
"iopub.status.busy": "2026-01-22T13:30:00.420630Z",
|
||||||
|
"iopub.status.idle": "2026-01-22T13:30:00.440823Z",
|
||||||
|
"shell.execute_reply": "2026-01-22T13:30:00.439903Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-22T13:30:00.421820Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"29\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import datetime\n",
|
||||||
|
"import csv\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"re_ta = {}\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/中心健康检测人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/marks_20260122.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",
|
||||||
|
"\n",
|
||||||
|
"for result in list1:\n",
|
||||||
|
" user = str(result[2])\n",
|
||||||
|
" rq = date.fromisoformat(result[5].replace('/','-'))\n",
|
||||||
|
" if user in dict1.keys():\n",
|
||||||
|
" #print(user)\n",
|
||||||
|
" l_xm = []\n",
|
||||||
|
" m_item = str(result[3]) \n",
|
||||||
|
" re_ta.setdefault(user,{}) \n",
|
||||||
|
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||||||
|
" re_ta[user]['sex'] = dict1[user]['sex']\n",
|
||||||
|
" re_ta[user]['birth'] = dict1[user]['birth']\n",
|
||||||
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
||||||
|
" if 'phone' in dict1[user].keys():\n",
|
||||||
|
" re_ta[user]['phone'] = dict1[user]['phone']\n",
|
||||||
|
" if dict1[user]['sex'] == '男':\n",
|
||||||
|
" l_xm = ['bmi','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
||||||
|
" else:\n",
|
||||||
|
" l_xm = ['bmi','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
||||||
|
" #re_ta[user]['unit'] = dict1[user]['unit']\n",
|
||||||
|
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
|
||||||
|
" item_name = result[3] \n",
|
||||||
|
" if item_name in l_xm: \n",
|
||||||
|
" days = (rq-birth).days \n",
|
||||||
|
" re_ta[user]['age'] = int(days/365)\n",
|
||||||
|
" re_ta[user]['month'] = int(days/365*12)\n",
|
||||||
|
" re_ta[user]['rq'] = result[5]\n",
|
||||||
|
" re_ta[user].setdefault(item_name,{}) \n",
|
||||||
|
" score = result[4] \n",
|
||||||
|
" re_ta[user][item_name]['成绩'] = score\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_中心健康检测人员.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||||
|
"print(len(re_ta))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "a882cae1-9df1-4267-ba07-82097f67ab05",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成测试得分"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "728c6978-bc53-44e4-b986-a13d5e2cd889",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-22T13:30:37.706987Z",
|
||||||
|
"iopub.status.busy": "2026-01-22T13:30:37.706464Z",
|
||||||
|
"iopub.status.idle": "2026-01-22T13:30:37.725209Z",
|
||||||
|
"shell.execute_reply": "2026-01-22T13:30:37.724253Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-22T13:30:37.706936Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok! 29\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import time\n",
|
||||||
|
"import my_module as My\n",
|
||||||
|
"\n",
|
||||||
|
"#list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','height','weight']\n",
|
||||||
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||||
|
"filename = 'data/result_中心健康检测人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl) \n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" #print(k)\n",
|
||||||
|
" if v['sex'] == '男':\n",
|
||||||
|
" sex = 'M'\n",
|
||||||
|
" else:\n",
|
||||||
|
" sex = 'F' \n",
|
||||||
|
" if 'bmi' in v.keys():\n",
|
||||||
|
" #bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
|
||||||
|
" bmi_data = v['bmi']['成绩']\n",
|
||||||
|
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':'HeightWeight','result':bmi_data}\n",
|
||||||
|
" dict2[k]['bmi'] = {}\n",
|
||||||
|
" dict2[k]['bmi']['成绩'] = bmi_data\n",
|
||||||
|
" dict2[k]['bmi']['score'] = My.cal_bmi(data1)\n",
|
||||||
|
" for item_en in list_item:\n",
|
||||||
|
" if item_en in v.keys(): \n",
|
||||||
|
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':item_en,'result':float(v[item_en]['成绩'].split()[0])}\n",
|
||||||
|
" #print(k,v['name'])\n",
|
||||||
|
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
|
||||||
|
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_中心健康检测人员.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||||
|
"print('ok!',len(dict2)) "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "64c5731f-ecb2-4524-8be0-0711926fe256",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 导入问卷信息"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "8dcfb696-7031-4647-b142-cf83c30d3a90",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 按照姓名导入"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 20,
|
||||||
|
"id": "5c90241e-b445-431a-8b59-66a40da2d1e6",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-22T13:52:46.021181Z",
|
||||||
|
"iopub.status.busy": "2026-01-22T13:52:46.020643Z",
|
||||||
|
"iopub.status.idle": "2026-01-22T13:52:46.038655Z",
|
||||||
|
"shell.execute_reply": "2026-01-22T13:52:46.037963Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-22T13:52:46.021130Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import csv\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import time\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"dict1 = {}\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_中心健康检测人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/sql_20260122.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",
|
||||||
|
" list1.append(line)\n",
|
||||||
|
"#print(list1)\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" \n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" content = json.loads(json.loads(item[1]))\n",
|
||||||
|
" name = content['name']\n",
|
||||||
|
" for k, v in dict1.items():\n",
|
||||||
|
" if v['name'] == name:\n",
|
||||||
|
" tcm = [] \n",
|
||||||
|
" for i in range(0,60):\n",
|
||||||
|
" tcm.append(0)\n",
|
||||||
|
" rq = date.fromisoformat(item[2].replace('/','-').split(' ')[0])\n",
|
||||||
|
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||||||
|
" \n",
|
||||||
|
" for k1, v1 in content.items(): \n",
|
||||||
|
" if 'tcm' in k1: \n",
|
||||||
|
" i = int(k1[3:])\n",
|
||||||
|
" tcm[i-1] = int(v1)\n",
|
||||||
|
" #print(tcm) \n",
|
||||||
|
" if 'tcm' in item[1]: \n",
|
||||||
|
" dict1[k]['tcm'] = tcm \n",
|
||||||
|
" \n",
|
||||||
|
" #dict1[k]['rq'] = rq\n",
|
||||||
|
"filename = 'data/result_中心健康检测人员.json'\n",
|
||||||
|
"\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(dict1, fl, ensure_ascii=False) "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e6606f92-76c1-434d-be3c-284ceb900f3f",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成报告"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 21,
|
||||||
|
"id": "d451cce5-e3a3-4909-bd13-807ddf82059a",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-22T13:55:59.725677Z",
|
||||||
|
"iopub.status.busy": "2026-01-22T13:55:59.725108Z",
|
||||||
|
"iopub.status.idle": "2026-01-22T13:56:14.228014Z",
|
||||||
|
"shell.execute_reply": "2026-01-22T13:56:14.226903Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-22T13:55:59.725621Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"29\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import requests\n",
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"headers = {\n",
|
||||||
|
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||||
|
" }\n",
|
||||||
|
"filename = 'data/result_中心健康检测人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"file_path ='./中心健康检测/'\n",
|
||||||
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||||
|
"i=0\n",
|
||||||
|
"list2 = []\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" list1 = []\n",
|
||||||
|
" mydata = {}\n",
|
||||||
|
" \n",
|
||||||
|
" id = str(k).rjust(4,\"0\")\n",
|
||||||
|
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
|
||||||
|
" mydata['title'] = '中心健康体质检测'\n",
|
||||||
|
" mydata['subtitle'] = v['unit']\n",
|
||||||
|
" mydata['id'] = id\n",
|
||||||
|
" mydata['name'] = v['name']\n",
|
||||||
|
" if v['sex'] == '男':\n",
|
||||||
|
" mydata['gender'] = 'male'\n",
|
||||||
|
" else:\n",
|
||||||
|
" mydata['gender'] = 'female'\n",
|
||||||
|
" \n",
|
||||||
|
" mydata['month'] = v['month']\n",
|
||||||
|
" mydata['fits'] = {}\n",
|
||||||
|
" survey_list = ['tcm','psy_yangmiao_old','spine']\n",
|
||||||
|
" for item in survey_list:\n",
|
||||||
|
" if item in v.keys():\n",
|
||||||
|
" mydata.setdefault('surveys',{})\n",
|
||||||
|
" mydata['surveys'][item] = v[item]\n",
|
||||||
|
" \n",
|
||||||
|
" \n",
|
||||||
|
" #mydata['fits'] = {}\n",
|
||||||
|
" for item in list_item:\n",
|
||||||
|
" if item in v.keys():\n",
|
||||||
|
" mydata.setdefault('fits',{})\n",
|
||||||
|
" if item in ['lung','pushup','step','situp']:\n",
|
||||||
|
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
||||||
|
" else:\n",
|
||||||
|
" mark = v[item]['成绩'].split()[0]\n",
|
||||||
|
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
|
||||||
|
" #if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n",
|
||||||
|
" #if len(mydata['fits']) >2 : \n",
|
||||||
|
" if len(mydata['fits']) >2 or 'surveys' in mydata.keys():\n",
|
||||||
|
" list1.append(mydata)\n",
|
||||||
|
" list2.append([k,v['name']])\n",
|
||||||
|
" i+=1\n",
|
||||||
|
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||||||
|
" #print(id,v['name'],x.text)\n",
|
||||||
|
" #print(mydata)\n",
|
||||||
|
" #x.close()\n",
|
||||||
|
"print(i)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "7dd43a2d-f467-44f1-89d8-b76461925297",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成体质检测明细表"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d991b368-46bc-47cc-81d1-591d636364d9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.12.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
+50
-130
@@ -74,16 +74,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": null,
|
||||||
"id": "d8abca28-6e1f-4f0a-a715-c1697cdf3f6a",
|
"id": "d8abca28-6e1f-4f0a-a715-c1697cdf3f6a",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2025-04-04T12:09:07.760344Z",
|
|
||||||
"iopub.status.busy": "2025-04-04T12:09:07.759806Z",
|
|
||||||
"iopub.status.idle": "2025-04-04T12:09:08.370898Z",
|
|
||||||
"shell.execute_reply": "2025-04-04T12:09:08.369913Z",
|
|
||||||
"shell.execute_reply.started": "2025-04-04T12:09:07.760298Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -114,17 +107,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": null,
|
||||||
"id": "62ff063a-5380-4e08-b115-acd967441ca4",
|
"id": "62ff063a-5380-4e08-b115-acd967441ca4",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2025-09-17T00:08:50.471131Z",
|
|
||||||
"iopub.status.busy": "2025-09-17T00:08:50.470548Z",
|
|
||||||
"iopub.status.idle": "2025-09-17T00:08:51.110490Z",
|
|
||||||
"shell.execute_reply": "2025-09-17T00:08:51.109925Z",
|
|
||||||
"shell.execute_reply.started": "2025-09-17T00:08:50.471076Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import os,sys,shutil\n",
|
"import os,sys,shutil\n",
|
||||||
@@ -1270,49 +1255,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 5,
|
"execution_count": null,
|
||||||
"id": "2f9f474d-265c-4beb-bd0e-53372ae9e57e",
|
"id": "2f9f474d-265c-4beb-bd0e-53372ae9e57e",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2025-12-03T04:26:40.331997Z",
|
|
||||||
"iopub.status.busy": "2025-12-03T04:26:40.331341Z",
|
|
||||||
"iopub.status.idle": "2025-12-03T04:26:41.149586Z",
|
|
||||||
"shell.execute_reply": "2025-12-03T04:26:41.149140Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-03T04:26:40.331947Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stderr",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"<>:51: SyntaxWarning: invalid escape sequence '\\s'\n",
|
|
||||||
"<>:51: SyntaxWarning: invalid escape sequence '\\s'\n",
|
|
||||||
"/tmp/ipykernel_1730998/3799497539.py:51: SyntaxWarning: invalid escape sequence '\\s'\n",
|
|
||||||
" data =[re.sub('\\s+', '', cell) if cell is not None else None for cell in row]\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"['姓名', '邵希强']\n",
|
|
||||||
"['性别', '男']\n",
|
|
||||||
"['测试标准', '国民体质测定标准']\n",
|
|
||||||
"['身高体重指数', '26.02', '60分']\n",
|
|
||||||
"['握力', '33.5千克', '50分']\n",
|
|
||||||
"['肺活量', '3050毫升', '70分']\n",
|
|
||||||
"['选择反应时', '0.572秒', '75分']\n",
|
|
||||||
"['指标', '您的结果', '亚洲男性平均值']\n",
|
|
||||||
"['臀围', '100', '88.82']\n",
|
|
||||||
"['身高腰围指数', '53.19', '42.79']\n",
|
|
||||||
"['建议类别', '建议项']\n",
|
|
||||||
"['增加摄入', '豆类、水果、蔬菜、坚果类、蛋类、菌类、乳制品、肉类']\n",
|
|
||||||
"['生活习惯', '提高睡眠质量、保持心情舒畅、换季时避开感染源、减少用眼']\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import pdfplumber\n",
|
"import pdfplumber\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -1384,33 +1332,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 13,
|
"execution_count": null,
|
||||||
"id": "b0764366-12cf-4880-8e0f-9ae18b46d392",
|
"id": "b0764366-12cf-4880-8e0f-9ae18b46d392",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2025-12-03T05:52:34.403674Z",
|
|
||||||
"iopub.status.busy": "2025-12-03T05:52:34.402297Z",
|
|
||||||
"iopub.status.idle": "2025-12-03T05:52:34.532929Z",
|
|
||||||
"shell.execute_reply": "2025-12-03T05:52:34.532427Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-03T05:52:34.403605Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"[['姓名', '邵希强']]\n",
|
|
||||||
"[['性别', '男']]\n",
|
|
||||||
"[['测试标准', '国民体质测定标准']]\n",
|
|
||||||
"[['身高体重指数', '26.02', '60分']]\n",
|
|
||||||
"[['握力', '33.5 千克', '50分']]\n",
|
|
||||||
"[['肺活量', '3050 毫升', '70分']]\n",
|
|
||||||
"[['选择反应时', '0.572 秒', '75分']]\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import pdfplumber\n",
|
"import pdfplumber\n",
|
||||||
"name = 'file/01730823-邵希强.pdf'\n",
|
"name = 'file/01730823-邵希强.pdf'\n",
|
||||||
@@ -1424,36 +1351,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 31,
|
"execution_count": null,
|
||||||
"id": "04dd6436-8374-4096-a2a3-d79f4d93a360",
|
"id": "04dd6436-8374-4096-a2a3-d79f4d93a360",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2025-12-04T01:29:08.571756Z",
|
|
||||||
"iopub.status.busy": "2025-12-04T01:29:08.571003Z",
|
|
||||||
"iopub.status.idle": "2025-12-04T01:29:08.644466Z",
|
|
||||||
"shell.execute_reply": "2025-12-04T01:29:08.643884Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-04T01:29:08.571687Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"['北体乾元健康管理中心', '姓名 邵希强', '中石化(天津)石油化工 编号 01730823', '有限公司 性别 男', '年龄 53', '国民体质检测结果与健康处方', '肺活量', '握力 身高体重指数', '坐位体前屈 选择反应时', '纵跳 闭眼单脚站立', '俯卧撑', '测试标准 国民体质测定标准', '闭眼单脚站立 2.8 秒 10分', '身高体重指数 26.02 60分', '坐位体前屈 13.5 厘米 90分', '握力 33.5 千克 50分', '纵跳 18.0 厘米 30分', '肺活量 3050 毫升 70分', '俯卧撑 5 次 50分', '选择反应时 0.572 秒 75分', '腰臀比 0.90 正常', '请注意:以上测试项目及格线为3分。列表中红色项目需重点关注,建议在专家指导下进行科学锻炼,', '减少潜在的运动风险。', '感谢您完成测试,以《国民体质测定标准》综合评级,您的总分为58分,等级为四级(不合格)。', '(其中项目纵跳因超出年龄范围得分仅供参考,不计入总分)', '北体乾元体质监测报告']\n",
|
|
||||||
"11 21\n",
|
|
||||||
"闭眼单脚站立\n",
|
|
||||||
"身高体重指数\n",
|
|
||||||
"坐位体前屈\n",
|
|
||||||
"握力\n",
|
|
||||||
"纵跳\n",
|
|
||||||
"肺活量\n",
|
|
||||||
"俯卧撑\n",
|
|
||||||
"选择反应时\n",
|
|
||||||
"腰臀比\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import pdfplumber\n",
|
"import pdfplumber\n",
|
||||||
"name = 'file/03499391-宋文路.pdf'\n",
|
"name = 'file/03499391-宋文路.pdf'\n",
|
||||||
@@ -1474,27 +1375,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 35,
|
"execution_count": null,
|
||||||
"id": "ac034bf9-cba9-4a72-87ba-d77721cc7097",
|
"id": "ac034bf9-cba9-4a72-87ba-d77721cc7097",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2025-12-08T01:54:24.900658Z",
|
|
||||||
"iopub.status.busy": "2025-12-08T01:54:24.900121Z",
|
|
||||||
"iopub.status.idle": "2025-12-08T01:54:24.960757Z",
|
|
||||||
"shell.execute_reply": "2025-12-08T01:54:24.960174Z",
|
|
||||||
"shell.execute_reply.started": "2025-12-08T01:54:24.900608Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"['北体乾元健康管理中心', '姓名 宋文路', '中石化(天津)石油化工 编号 03499391', '有限公司 性别 男', '年龄 26', '国民体质检测结果与健康处方', '握力', '纵跳 身高体重指数', '选择反应时', '测试标准 国民体质测定标准', '身高体重指数 33.68 20分', '握力 38.6 千克 55分', '纵跳 22.8 厘米 30分', '选择反应时 0.466 秒 90分', '腰臀比 0.95 正常', '请注意:以上测试项目及格线为60分。列表中红色项目需重点关注,建议在专家指导下进行科学锻炼,', '减少潜在的运动风险。', '感谢您完成测试,因为您未完成肺活量、台阶指数、俯卧撑、1分钟仰卧起坐、坐位体前屈、闭眼单脚', '站立,无法以《国民体质测定标准》综合评级,改为以平均分作为综合评级参考。您的平均得分为53,等级', '为四级(不合格),仅供参考。', '北体乾元体质监测报告']\n",
|
|
||||||
"感谢您完成测试,因为您未完成肺活量、台阶指数、俯卧撑、1分钟仰卧起坐、坐位体前屈、闭眼单脚站立,无法以《国民体质测定标准》综合评级,改为以平均分作为综合评级参考。您的平均得分为53,等级为四级(不合格),仅供参考。北体乾元体质监测报告\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import pdfplumber\n",
|
"import pdfplumber\n",
|
||||||
"name = 'file/03499391-宋文路.pdf'\n",
|
"name = 'file/03499391-宋文路.pdf'\n",
|
||||||
@@ -1510,10 +1394,46 @@
|
|||||||
" print(ss)"
|
" print(ss)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "26623725-92da-48d9-a476-78a1befd06ef",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 合并PDF文件"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"id": "9b37b17e-66d3-4acc-8edb-760ea17123b4",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2026-01-17T11:13:57.369456Z",
|
||||||
|
"iopub.status.busy": "2026-01-17T11:13:57.368880Z",
|
||||||
|
"iopub.status.idle": "2026-01-17T11:13:59.005588Z",
|
||||||
|
"shell.execute_reply": "2026-01-17T11:13:59.004975Z",
|
||||||
|
"shell.execute_reply.started": "2026-01-17T11:13:57.369401Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from pypdf import PdfWriter\n",
|
||||||
|
"import glob\n",
|
||||||
|
"\n",
|
||||||
|
"fi_path = 'file/2025/'\n",
|
||||||
|
"fls = glob.glob(f'{fi_path}*.pdf')\n",
|
||||||
|
"fls.sort()\n",
|
||||||
|
"merger = PdfWriter()\n",
|
||||||
|
"for pdf in fls:\n",
|
||||||
|
" merger.append(pdf)\n",
|
||||||
|
"merger.write(\"file/2025年明细账.pdf\")\n",
|
||||||
|
"merger.close()\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "41177ae9-d7ae-45c2-90b5-94578699215e",
|
"id": "6d5c9dd3-bd09-49b3-8a22-07bb4440aace",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
Reference in new issue
Block a user