From 689c26b967e90ed54f677747c82463c398b17dbd Mon Sep 17 00:00:00 2001 From: 512song Date: Tue, 16 Sep 2025 13:14:59 +0800 Subject: [PATCH] 20250916 --- 体测单位/体质检测数据处理.ipynb | 40 +++-- 体测单位/北海炼化.ipynb | 8 +- 体测单位/南京化工.ipynb | 205 +++++++++++++++++--------- 体测单位/宁夏能化.ipynb | 49 ++++++ 体测单位/新疆油田采油工艺研究院.ipynb | 77 ++++++++-- 体测单位/海淀老干部大学.ipynb | 69 ++++++++- 文件管理.ipynb | 64 +++++++- 7 files changed, 396 insertions(+), 116 deletions(-) diff --git a/体测单位/体质检测数据处理.ipynb b/体测单位/体质检测数据处理.ipynb index c47f845..31f4472 100644 --- a/体测单位/体质检测数据处理.ipynb +++ b/体测单位/体质检测数据处理.ipynb @@ -2376,15 +2376,15 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19", "metadata": { "execution": { - "iopub.execute_input": "2025-07-27T15:45:05.548263Z", - "iopub.status.busy": "2025-07-27T15:45:05.547435Z", - "iopub.status.idle": "2025-07-27T15:45:05.559268Z", - "shell.execute_reply": "2025-07-27T15:45:05.558385Z", - "shell.execute_reply.started": "2025-07-27T15:45:05.548183Z" + "iopub.execute_input": "2025-09-16T02:05:51.668240Z", + "iopub.status.busy": "2025-09-16T02:05:51.667590Z", + "iopub.status.idle": "2025-09-16T02:05:51.678339Z", + "shell.execute_reply": "2025-09-16T02:05:51.677348Z", + "shell.execute_reply.started": "2025-09-16T02:05:51.668169Z" } }, "outputs": [], @@ -2502,7 +2502,17 @@ "list2 = ['成就感','愉快心境','放松程度','压力应对','体力充沛','情感充沛度']\n", "list3 = [[5,7],[7,4],[7,4],[7,4],[8,1],[6,1]] \n", "list4 = ['颈椎','胸椎','腰椎','骶尾椎']\n", - "list5 = [[0,10,10],[10,17,7],[17,24,6],[24,26,2]]" + "list5 = [[0,10,10],[10,17,7],[17,24,6],[24,26,2]]\n", + "\n", + "\n", + "qb = [\n", + " 1, 1, 1, 1, 1,\n", + " 4, 3, 2, 3, 2, 4, 3,\n", + " 4, 3, 2, 4, 4, 2, 4,\n", + " 3, 2, 2, 4, 3, 3, 2,\n", + " 5, 5, 5, 5, 5, 5, 5, 5,\n", + " 6, 6, 6, 6, 6, 6\n", + " ]" ] }, { @@ -2742,15 +2752,15 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "9ecd3ad8-c8af-4f3e-90e5-1618fea905a4", "metadata": { "execution": { - "iopub.execute_input": "2025-07-27T15:47:28.099497Z", - "iopub.status.busy": "2025-07-27T15:47:28.098682Z", - "iopub.status.idle": "2025-07-27T15:47:28.154741Z", - "shell.execute_reply": "2025-07-27T15:47:28.154263Z", - "shell.execute_reply.started": "2025-07-27T15:47:28.099431Z" + "iopub.execute_input": "2025-09-16T02:06:01.244917Z", + "iopub.status.busy": "2025-09-16T02:06:01.244267Z", + "iopub.status.idle": "2025-09-16T02:06:01.629798Z", + "shell.execute_reply": "2025-09-16T02:06:01.629334Z", + "shell.execute_reply.started": "2025-09-16T02:06:01.244858Z" } }, "outputs": [], @@ -2758,7 +2768,7 @@ "import openpyxl\n", "\n", "list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n", - "filename = 'data/result_新疆油田采油工艺研究院-1.json'\n", + "filename = 'data/result_北海炼化2023.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "data_list = []\n", @@ -2840,7 +2850,7 @@ " list6.append('')\n", " i+=1\n", " data_list.append(list6)\n", - "filename = 'data/新疆油田采油工艺研究院测试情况表.xlsx'\n", + "filename = 'data/北海炼化测试情况表2023.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "#sheet.append(title)\n", diff --git a/体测单位/北海炼化.ipynb b/体测单位/北海炼化.ipynb index 1dc22e4..b5e3008 100644 --- a/体测单位/北海炼化.ipynb +++ b/体测单位/北海炼化.ipynb @@ -1982,9 +1982,7 @@ { "cell_type": "markdown", "id": "a51dadfb-30e7-40f3-a437-321aa986a10f", - "metadata": { - "jp-MarkdownHeadingCollapsed": true - }, + "metadata": {}, "source": [ "# 北海体检情况汇总" ] @@ -2091,7 +2089,9 @@ { "cell_type": "markdown", "id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc", - "metadata": {}, + "metadata": { + "jp-MarkdownHeadingCollapsed": true + }, "source": [ "# 2024年体质检测" ] diff --git a/体测单位/南京化工.ipynb b/体测单位/南京化工.ipynb index 9a5107f..3874abd 100644 --- a/体测单位/南京化工.ipynb +++ b/体测单位/南京化工.ipynb @@ -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", diff --git a/体测单位/宁夏能化.ipynb b/体测单位/宁夏能化.ipynb index 8b8e504..2351867 100644 --- a/体测单位/宁夏能化.ipynb +++ b/体测单位/宁夏能化.ipynb @@ -340,6 +340,55 @@ "wb.save(filename)" ] }, + { + "cell_type": "code", + "execution_count": 2, + "id": "75b98b19-ab32-414a-b3f2-6efd58e1f9a9", + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-28T09:16:02.802494Z", + "iopub.status.busy": "2025-08-28T09:16:02.801898Z", + "iopub.status.idle": "2025-08-28T09:16:02.994884Z", + "shell.execute_reply": "2025-08-28T09:16:02.994340Z", + "shell.execute_reply.started": "2025-08-28T09:16:02.802438Z" + } + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n", + "title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "\n", + "filename = 'data/result_宁夏能化人员all.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "\n", + "filename = 'data/宁夏能化人员all.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", + " \n", + "list1 = []\n", + "for k, v in dict1.items():\n", + " list2 = []\n", + " list2.append(str(k).rjust(5,'0'))\n", + " list2.append(v['name']) \n", + " list2.append(v['sex'])\n", + " list2.append(v['unit'])\n", + " list2.append(v['age'])\n", + " \n", + " list1.append(list2)\n", + "filename = 'data/宁夏能化测试人员年龄情况明细表.xlsx'\n", + "wb = openpyxl.Workbook()\n", + "sheet = wb.active\n", + "sheet.append(title)\n", + "for row in list1:\n", + " sheet.append(row)\n", + " \n", + "wb.save(filename)" + ] + }, { "cell_type": "markdown", "id": "699c6a40-a6ae-4300-9646-708cb85aa5e8", diff --git a/体测单位/新疆油田采油工艺研究院.ipynb b/体测单位/新疆油田采油工艺研究院.ipynb index 03f3f1f..16bf4a8 100644 --- a/体测单位/新疆油田采油工艺研究院.ipynb +++ b/体测单位/新疆油田采油工艺研究院.ipynb @@ -47,10 +47,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "de3144e7-544a-4430-bf69-3d20479d50c9", - "metadata": {}, - "outputs": [], + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-25T07:09:50.818045Z", + "iopub.status.busy": "2025-08-25T07:09:50.817355Z", + "iopub.status.idle": "2025-08-25T07:09:51.017532Z", + "shell.execute_reply": "2025-08-25T07:09:51.017045Z", + "shell.execute_reply.started": "2025-08-25T07:09:50.817980Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "30 ok\n" + ] + } + ], "source": [ "import openpyxl\n", "import json\n", @@ -90,12 +106,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "970e171e-1360-448f-a28c-520ccb8f314a", "metadata": { + "execution": { + "iopub.execute_input": "2025-08-25T07:10:06.792695Z", + "iopub.status.busy": "2025-08-25T07:10:06.791764Z", + "iopub.status.idle": "2025-08-25T07:10:06.809711Z", + "shell.execute_reply": "2025-08-25T07:10:06.808745Z", + "shell.execute_reply.started": "2025-08-25T07:10:06.792617Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "25\n" + ] + } + ], "source": [ "import json\n", "import datetime\n", @@ -152,10 +183,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b", - "metadata": {}, - "outputs": [], + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-25T07:13:08.181827Z", + "iopub.status.busy": "2025-08-25T07:13:08.181087Z", + "iopub.status.idle": "2025-08-25T07:13:08.195674Z", + "shell.execute_reply": "2025-08-25T07:13:08.194568Z", + "shell.execute_reply.started": "2025-08-25T07:13:08.181758Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok!\n" + ] + } + ], "source": [ "import json\n", "import time\n", @@ -186,7 +233,7 @@ " dict2[k][item_en]['score'] = My.cal_score(data1)\n", " #print(k,v[item_en]['成绩'],cal_score(data1))\n", "\n", - "filename = f'data/result_新疆油田采油工艺研究院1.json'\n", + "filename = f'data/result_新疆油田采油工艺研究院1-1.json'\n", "with open(filename,'w') as fl:\n", " json.dump(dict2,fl , ensure_ascii=False) \n", "print('ok!') " @@ -524,11 +571,11 @@ "id": "23ffd115-72a3-4f90-9e64-ffa6420df8a4", "metadata": { "execution": { - "iopub.execute_input": "2025-08-13T02:43:03.163356Z", - "iopub.status.busy": "2025-08-13T02:43:03.162804Z", - "iopub.status.idle": "2025-08-13T02:43:17.799933Z", - "shell.execute_reply": "2025-08-13T02:43:17.799273Z", - "shell.execute_reply.started": "2025-08-13T02:43:03.163305Z" + "iopub.execute_input": "2025-08-25T07:13:29.388206Z", + "iopub.status.busy": "2025-08-25T07:13:29.387452Z", + "iopub.status.idle": "2025-08-25T07:13:42.980504Z", + "shell.execute_reply": "2025-08-25T07:13:42.979631Z", + "shell.execute_reply.started": "2025-08-25T07:13:29.388132Z" } }, "outputs": [ @@ -536,7 +583,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "24\n" + "25\n" ] } ], diff --git a/体测单位/海淀老干部大学.ipynb b/体测单位/海淀老干部大学.ipynb index 8362da6..b74a5dd 100644 --- a/体测单位/海淀老干部大学.ipynb +++ b/体测单位/海淀老干部大学.ipynb @@ -47,7 +47,7 @@ " dict1 = {}\n", " dict1['name'] = sheet.cell(n, 2).value\n", " dict1['sex'] = sheet.cell(n, 3).value\n", - " dict1['unit'] = '第二期'\n", + " dict1['unit'] = '第三期'\n", " dict1['birth'] = str(sheet.cell(n, 4).value).replace('/','-').split(' ')[0]\n", " dict1['id'] = sheet.cell(n, 5).value\n", " if sheet.cell(n,6).value is not None:\n", @@ -60,6 +60,59 @@ "print('ok')" ] }, + { + "cell_type": "code", + "execution_count": 3, + "id": "a5cc3bda-6381-438c-822a-5b5a51771143", + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-28T05:29:40.352838Z", + "iopub.status.busy": "2025-08-28T05:29:40.352130Z", + "iopub.status.idle": "2025-08-28T05:29:40.378000Z", + "shell.execute_reply": "2025-08-28T05:29:40.377427Z", + "shell.execute_reply.started": "2025-08-28T05:29:40.352773Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "46\n", + "ok\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "from datetime import date\n", + "\n", + "wb = openpyxl.load_workbook('data/海淀老干部局2025年秋季报名表.xlsx')\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", + " dict1['unit'] = '2025年秋季'\n", + " dict1['birth'] = str(sheet.cell(n, 4).value).replace('/','-').split(' ')[0]\n", + " dict1['id'] = sheet.cell(n, 5).value\n", + " if sheet.cell(n,6).value is not None:\n", + " dict1['phone'] = str(sheet.cell(n,6).value) \n", + " person[code] = dict1\n", + "filename = 'data/海淀区老干部大学2025年秋季.json'\n", + "with open(filename, 'w') as fl:\n", + " json.dump(person, fl, ensure_ascii=False)\n", + "print(len(person))\n", + "print('ok')\n", + "\n" + ] + }, { "cell_type": "markdown", "id": "40f2c77d-1504-4288-9ed0-a0a4678579ee", @@ -70,15 +123,15 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "id": "4e0de75e-6957-434a-9591-da96c21f4659", "metadata": { "execution": { - "iopub.execute_input": "2025-03-03T07:21:43.877959Z", - "iopub.status.busy": "2025-03-03T07:21:43.877156Z", - "iopub.status.idle": "2025-03-03T07:21:43.888327Z", - "shell.execute_reply": "2025-03-03T07:21:43.887102Z", - "shell.execute_reply.started": "2025-03-03T07:21:43.877887Z" + "iopub.execute_input": "2025-08-28T05:29:44.681746Z", + "iopub.status.busy": "2025-08-28T05:29:44.680983Z", + "iopub.status.idle": "2025-08-28T05:29:44.691981Z", + "shell.execute_reply": "2025-08-28T05:29:44.690831Z", + "shell.execute_reply.started": "2025-08-28T05:29:44.681674Z" } }, "outputs": [ @@ -93,7 +146,7 @@ "source": [ "import json\n", "\n", - "filename = 'data/海淀区老干部大学第一期.json'\n", + "filename = 'data/海淀区老干部大学2025年秋季.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "list1 = []\n", diff --git a/文件管理.ipynb b/文件管理.ipynb index 48936d0..6409c47 100644 --- a/文件管理.ipynb +++ b/文件管理.ipynb @@ -104,6 +104,66 @@ " " ] }, + { + "cell_type": "markdown", + "id": "e22401f7-9c02-4c4b-a935-e844e56d099b", + "metadata": {}, + "source": [ + "## 汇总目录下所有文件" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "11ff2c59-5815-42c9-abaf-71c8c2a3b7da", + "metadata": {}, + "outputs": [], + "source": [ + "import os,sys,shutil\n", + "from pathlib import Path\n", + "\n", + "fi_path = 'file/北海/未参加体测人员报告'\n", + "new_path = 'file/北海/new/未参加体测人员'\n", + "pdf_files = list(fi_path.glob('**/*.pdf'))\n", + "\n", + "for fn in fls:\n", + " fi_name =Path(fn).stem.split('-')[0]\n", + " code = int(fi_name) \n", + " unit_path = Path(new_path,dict1[str(code)]['unit'])\n", + " unit_path.mkdir(parents = True, exist_ok = True)\n", + " n_name = Path(unit_path,Path(fn).stem+'.pdf')\n", + " #if not os.path.exists(n_name):\n", + " shutil.copyfile(fn,n_name)\n", + " print(fn)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "62ff063a-5380-4e08-b115-acd967441ca4", + "metadata": { + "execution": { + "iopub.execute_input": "2025-09-16T02:36:40.592582Z", + "iopub.status.busy": "2025-09-16T02:36:40.591749Z", + "iopub.status.idle": "2025-09-16T02:36:40.635821Z", + "shell.execute_reply": "2025-09-16T02:36:40.635329Z", + "shell.execute_reply.started": "2025-09-16T02:36:40.592518Z" + } + }, + "outputs": [], + "source": [ + "import os,sys,shutil\n", + "from pathlib import Path\n", + "\n", + "fi_path =Path('file/北海/未参加体测人员报告')\n", + "new_path = 'file/北海/new/未参加体测人员'\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", "execution_count": null, @@ -1370,7 +1430,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1384,7 +1444,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.12.3" } }, "nbformat": 4,