This commit is contained in:
512song committed 2025-07-23 19:14:18 +08:00
1 parent 321337fdda
commit f753563cc6
3 files changed
+143 -165

No files matched your search

+83 -108
View File
@@ -10,27 +10,12 @@
},
{
"cell_type": "code",
"execution_count": 75,
"execution_count": null,
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:10:10.030695Z",
"iopub.status.busy": "2025-07-03T14:10:10.030380Z",
"iopub.status.idle": "2025-07-03T14:10:10.104203Z",
"shell.execute_reply": "2025-07-03T14:10:10.103560Z",
"shell.execute_reply.started": "2025-07-03T14:10:10.030662Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"92 ok\n"
]
}
],
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
@@ -105,27 +90,12 @@
},
{
"cell_type": "code",
"execution_count": 76,
"execution_count": null,
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:10:45.274585Z",
"iopub.status.busy": "2025-07-03T14:10:45.273833Z",
"iopub.status.idle": "2025-07-03T14:10:45.293613Z",
"shell.execute_reply": "2025-07-03T14:10:45.292999Z",
"shell.execute_reply.started": "2025-07-03T14:10:45.274514Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"86\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import datetime\n",
@@ -156,26 +126,10 @@
},
{
"cell_type": "code",
"execution_count": 77,
"execution_count": null,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:10:49.291562Z",
"iopub.status.busy": "2025-07-03T14:10:49.290910Z",
"iopub.status.idle": "2025-07-03T14:10:49.313086Z",
"shell.execute_reply": "2025-07-03T14:10:49.312338Z",
"shell.execute_reply.started": "2025-07-03T14:10:49.291501Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -287,16 +241,9 @@
},
{
"cell_type": "code",
"execution_count": 78,
"execution_count": null,
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:11:05.924023Z",
"iopub.status.busy": "2025-07-03T14:11:05.923517Z",
"iopub.status.idle": "2025-07-03T14:11:05.951213Z",
"shell.execute_reply": "2025-07-03T14:11:05.950561Z",
"shell.execute_reply.started": "2025-07-03T14:11:05.923975Z"
},
"tags": []
},
"outputs": [],
@@ -317,7 +264,7 @@
"for k,v in dict1.items():\n",
" phone1.add(v['phone'])\n",
"list1 = []\n",
"filename = 'data/survey_records_20250703.csv'\n",
"filename = 'data/survey_records_20250711.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -349,27 +296,10 @@
},
{
"cell_type": "code",
"execution_count": 79,
"execution_count": null,
"id": "9cb0172e-5f6c-4b47-8431-83dc5cc4601c",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:11:09.342124Z",
"iopub.status.busy": "2025-07-03T14:11:09.341492Z",
"iopub.status.idle": "2025-07-03T14:11:09.352176Z",
"shell.execute_reply": "2025-07-03T14:11:09.350856Z",
"shell.execute_reply.started": "2025-07-03T14:11:09.342065Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"13718042132\n",
"13705162311\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
@@ -387,7 +317,7 @@
"for k,v in dict1.items():\n",
" phone1.add(v['phone'])\n",
"list1 = []\n",
"filename = 'data/survey_records_20250701.csv'\n",
"filename = 'data/survey_records_20250711.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -410,17 +340,9 @@
},
{
"cell_type": "code",
"execution_count": 80,
"execution_count": null,
"id": "9d9dd574-9fbf-4d0a-96fd-9b55d98021d2",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:11:25.002448Z",
"iopub.status.busy": "2025-07-03T14:11:25.001635Z",
"iopub.status.idle": "2025-07-03T14:11:25.029582Z",
"shell.execute_reply": "2025-07-03T14:11:25.029137Z",
"shell.execute_reply.started": "2025-07-03T14:11:25.002370Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -444,7 +366,7 @@
" phone[v['phone']] = k\n",
"\n",
"list1 = []\n",
"filename = 'data/survey_records_20250703.csv'\n",
"filename = 'data/survey_records_20250711.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -504,17 +426,9 @@
},
{
"cell_type": "code",
"execution_count": 81,
"execution_count": null,
"id": "4a0678c6-0c64-4314-bb03-24b10a3d695a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:11:29.937365Z",
"iopub.status.busy": "2025-07-03T14:11:29.936849Z",
"iopub.status.idle": "2025-07-03T14:11:29.966917Z",
"shell.execute_reply": "2025-07-03T14:11:29.966365Z",
"shell.execute_reply.started": "2025-07-03T14:11:29.937316Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -545,6 +459,67 @@
" json.dump(dict1, fl, ensure_ascii=False)\n"
]
},
{
"cell_type": "markdown",
"id": "caf77c95-3090-4fa1-bcec-c9e8a38d4ca9",
"metadata": {},
"source": [
"## 体检报告汇总"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "b815a478-d178-4b87-9080-a779d397d945",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-23T11:12:10.951052Z",
"iopub.status.busy": "2025-07-23T11:12:10.950295Z",
"iopub.status.idle": "2025-07-23T11:12:11.030914Z",
"shell.execute_reply": "2025-07-23T11:12:11.030243Z",
"shell.execute_reply.started": "2025-07-23T11:12:10.950983Z"
}
},
"outputs": [
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: 'file/南化体重/new/1789748-姜吉元.pdf'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[17], line 20\u001b[0m\n\u001b[1;32m 18\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m name \u001b[38;5;241m==\u001b[39m v[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m]:\n\u001b[1;32m 19\u001b[0m n_name \u001b[38;5;241m=\u001b[39m Path(new_path,\u001b[38;5;28mstr\u001b[39m(k)\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m+\u001b[39mname\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.pdf\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m---> 20\u001b[0m \u001b[43mshutil\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcopyfile\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfl\u001b[49m\u001b[43m,\u001b[49m\u001b[43mn_name\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 21\u001b[0m \u001b[38;5;28mprint\u001b[39m(n_name)\n",
"File \u001b[0;32m/usr/lib/python3.12/shutil.py:262\u001b[0m, in \u001b[0;36mcopyfile\u001b[0;34m(src, dst, follow_symlinks)\u001b[0m\n\u001b[1;32m 260\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(src, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrb\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m fsrc:\n\u001b[1;32m 261\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 262\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mdst\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mwb\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m fdst:\n\u001b[1;32m 263\u001b[0m \u001b[38;5;66;03m# macOS\u001b[39;00m\n\u001b[1;32m 264\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m _HAS_FCOPYFILE:\n\u001b[1;32m 265\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'file/南化体重/new/1789748-姜吉元.pdf'"
]
}
],
"source": [
"from pathlib import Path\n",
"import json\n",
"import shutil\n",
"\n",
"\n",
"target_directory = Path('./file/南化体重')\n",
"new_path = './file/南化体重/new'\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"# 遍历目标目录及其子目录获取所有文件\n",
"\n",
"for fl in target_directory.rglob('*.pdf'):\n",
" if fl.is_file():\n",
" fl_name = fl.stem\n",
" name = fl_name[12:] \n",
" for k, v in dict1.items(): \n",
" if name == v['name']:\n",
" n_name = Path(new_path,str(k)+'-'+name+'.pdf')\n",
" shutil.copyfile(fl,n_name)\n",
" print(n_name)\n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"id": "8d5f4103-0d1e-4711-b324-ece360f8dcd3",
@@ -568,7 +543,7 @@
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_南京化工.json'\n",
"filename = 'data/result_南京化工-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -582,7 +557,7 @@
" \n",
" id = str(k).rjust(4,\"0\")\n",
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
" mydata['title'] = '江苏油田'\n",
" mydata['title'] = '南化公司'\n",
" mydata['subtitle'] = v['unit']\n",
" mydata['id'] = id\n",
" mydata['name'] = v['name']\n",
@@ -609,8 +584,8 @@
" 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 len(mydata['surveys']) >0:\n",
" #if len(mydata['fits']) >2 : \n",
" list1.append(mydata)\n",
" list2.append([k,v['name']])\n",
" i+=1\n",