20250916
This commit is contained in:
1 parent
5bd40c3755
commit
689c26b967
7 files changed
+396
-116
No files matched your search
+133
-72
@@ -435,18 +435,26 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 60,
|
||||
"execution_count": 19,
|
||||
"id": "9b801085-ca98-4958-8dcc-bcd9985fcd4b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-08-20T04:29:28.410551Z",
|
||||
"iopub.status.busy": "2025-08-20T04:29:28.403719Z",
|
||||
"iopub.status.idle": "2025-08-20T04:29:28.443048Z",
|
||||
"shell.execute_reply": "2025-08-20T04:29:28.440751Z",
|
||||
"shell.execute_reply.started": "2025-08-20T04:29:28.410496Z"
|
||||
"iopub.execute_input": "2025-09-01T07:20:37.177771Z",
|
||||
"iopub.status.busy": "2025-09-01T07:20:37.177055Z",
|
||||
"iopub.status.idle": "2025-09-01T07:20:37.198841Z",
|
||||
"shell.execute_reply": "2025-09-01T07:20:37.198253Z",
|
||||
"shell.execute_reply.started": "2025-09-01T07:20:37.177707Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"83\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
@@ -461,7 +469,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/survey_records_20250820.csv'\n",
|
||||
"filename = 'data/survey_records_20250901.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -478,7 +486,13 @@
|
||||
" \n",
|
||||
" content = json.loads(item[4]) \n",
|
||||
" phone = content['phone']\n",
|
||||
" dict1.setdefault(phone,{})\n",
|
||||
" name = content['name']\n",
|
||||
" for k,v in dict3.items():\n",
|
||||
" if name == v['name']:\n",
|
||||
" code = k\n",
|
||||
" unit = v['unit']\n",
|
||||
" sex = v['sex']\n",
|
||||
" dict1.setdefault(code,{})\n",
|
||||
" \n",
|
||||
" #rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n",
|
||||
" #dict1[phone]['rq'] = str(date.fromisoformat(item[5].replace('/','-').split(' ')[0]))\n",
|
||||
@@ -489,19 +503,21 @@
|
||||
" tcm[i-1] = int(v) \n",
|
||||
" \n",
|
||||
" if 'tcm' in item[4]: \n",
|
||||
" dict1[phone]['tcm'] = tcm\n",
|
||||
" dict1[code]['tcm'] = tcm\n",
|
||||
" \n",
|
||||
" dict1[phone]['name'] = content['name']\n",
|
||||
" dict1[phone]['sex'] = content['gender']\n",
|
||||
" dict1[phone]['weight'] = content['weight']\n",
|
||||
" dict1[phone]['tun'] = content['hip']\n",
|
||||
" dict1[phone]['yao'] = content['waist']\n",
|
||||
" dict1[code]['name'] = content['name']\n",
|
||||
" dict1[code]['unit'] = unit\n",
|
||||
" dict1[code]['sex'] = sex\n",
|
||||
" dict1[code]['weight'] = content['weight']\n",
|
||||
" dict1[code]['tun'] = content['hip']\n",
|
||||
" dict1[code]['yao'] = content['waist']\n",
|
||||
" #print(phone[item[2]])\n",
|
||||
" nn+=1\n",
|
||||
"filename = 'data/result_南京化工-2.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False)"
|
||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||
"print(len(dict1))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -557,26 +573,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 62,
|
||||
"execution_count": null,
|
||||
"id": "e233e6c3-9c3f-42c7-8057-012bbcfe8b26",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-08-20T04:29:47.260065Z",
|
||||
"iopub.status.busy": "2025-08-20T04:29:47.255846Z",
|
||||
"iopub.status.idle": "2025-08-20T04:29:47.343088Z",
|
||||
"shell.execute_reply": "2025-08-20T04:29:47.342363Z",
|
||||
"shell.execute_reply.started": "2025-08-20T04:29:47.260018Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
@@ -722,7 +722,7 @@
|
||||
" list3.append(item)\n",
|
||||
" list2.append(list3)\n",
|
||||
"\n",
|
||||
"filename = 'data/南化第二次问卷明细表(截至20250820).xlsx'\n",
|
||||
"filename = 'data/南化第二次问卷明细表(截至20250831).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"\n",
|
||||
@@ -789,8 +789,8 @@
|
||||
"#llama_docs = llama_reader.load_data(\"data/1782596-唐荣.pdf\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"target_directory = Path('./file/南化体重/new')\n",
|
||||
"new_path = './file/南化体重/md'\n",
|
||||
"target_directory = Path('./file/北海体检报告')\n",
|
||||
"new_path = './file/北海体检报告/md'\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"for fl in target_directory.rglob('*.pdf'):\n",
|
||||
@@ -846,11 +846,11 @@
|
||||
"headers = {\n",
|
||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||
" }\n",
|
||||
"filename = 'data/result_南京化工-1.json'\n",
|
||||
"filename = 'data/result_南京化工-2.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"file_path ='./南京化工/'\n",
|
||||
"file_path ='./南京化工第二批问卷/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i=0\n",
|
||||
"list2 = []\n",
|
||||
@@ -861,7 +861,7 @@
|
||||
" 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['subtitle'] = ''#v['unit']\n",
|
||||
" mydata['id'] = id\n",
|
||||
" mydata['name'] = v['name']\n",
|
||||
" if v['sex'] == '男':\n",
|
||||
@@ -899,6 +899,91 @@
|
||||
"print(i)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "007a67c3-3590-47d9-a6d3-9080574a7940",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 生成报告(单问卷)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"id": "fc2bfab2-7f56-4abf-b2c4-0fb49a0da563",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-09-01T07:20:49.606201Z",
|
||||
"iopub.status.busy": "2025-09-01T07:20:49.605939Z",
|
||||
"iopub.status.idle": "2025-09-01T07:21:08.746449Z",
|
||||
"shell.execute_reply": "2025-09-01T07:21:08.745281Z",
|
||||
"shell.execute_reply.started": "2025-09-01T07:20:49.606179Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"83\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_南京化工-2.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)\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'] == 'm':\n",
|
||||
" mydata['gender'] = 'male'\n",
|
||||
" else:\n",
|
||||
" mydata['gender'] = 'female'\n",
|
||||
" \n",
|
||||
" #mydata['month'] = v['month']\n",
|
||||
" #mydata['fits'] = {}\n",
|
||||
" survey_list = ['tcm','psy57','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",
|
||||
" \n",
|
||||
" if len(mydata['surveys']) >0:\n",
|
||||
" #if len(mydata['fits']) >2 : \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": "42f1a67c-756a-4cf0-bd53-d71fb9c95aa6",
|
||||
@@ -909,17 +994,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 53,
|
||||
"execution_count": null,
|
||||
"id": "c2fb2c7c-6541-4c41-ba38-0e1fee29aa97",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-08-14T11:18:53.769605Z",
|
||||
"iopub.status.busy": "2025-08-14T11:18:53.769133Z",
|
||||
"iopub.status.idle": "2025-08-14T11:18:53.803613Z",
|
||||
"shell.execute_reply": "2025-08-14T11:18:53.803014Z",
|
||||
"shell.execute_reply.started": "2025-08-14T11:18:53.769567Z"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
@@ -1013,17 +1090,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 54,
|
||||
"execution_count": null,
|
||||
"id": "daa1b36e-1b62-49ee-9539-84c2d286fefe",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-08-14T11:19:18.851515Z",
|
||||
"iopub.status.busy": "2025-08-14T11:19:18.850941Z",
|
||||
"iopub.status.idle": "2025-08-14T11:19:18.941694Z",
|
||||
"shell.execute_reply": "2025-08-14T11:19:18.941103Z",
|
||||
"shell.execute_reply.started": "2025-08-14T11:19:18.851460Z"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
@@ -1081,17 +1150,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 55,
|
||||
"execution_count": null,
|
||||
"id": "221b35dc-3a17-4950-993c-b634ee9a53cf",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-08-15T00:53:31.414664Z",
|
||||
"iopub.status.busy": "2025-08-15T00:53:31.413959Z",
|
||||
"iopub.status.idle": "2025-08-15T00:53:32.212146Z",
|
||||
"shell.execute_reply": "2025-08-15T00:53:32.211576Z",
|
||||
"shell.execute_reply.started": "2025-08-15T00:53:31.414598Z"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from spire.pdf.common import *\n",
|
||||
@@ -1101,7 +1162,7 @@
|
||||
"pdf = PdfDocument()\n",
|
||||
"\n",
|
||||
"# 加载PDF文档\n",
|
||||
"pdf.LoadFromFile(\"file/南化体重/new/1782596-唐荣.pdf\")\n",
|
||||
"pdf.LoadFromFile(\"file/北海体检报告/2405280074.pdf\")\n",
|
||||
"\n",
|
||||
"# 将PDF转换为Markdown文件\n",
|
||||
"pdf.SaveToFile(\"PDF转Markdown.md\", FileFormat.Markdown)\n",
|
||||
|
||||
Reference in new issue
Block a user