From 55130611377fe092dc80c51c6ecba617cbbefe77 Mon Sep 17 00:00:00 2001 From: 512song Date: Thu, 3 Nov 2022 21:25:04 +0800 Subject: [PATCH] 2022111304 --- 体测单位/巴陵石化.ipynb | 77 +++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/体测单位/巴陵石化.ipynb b/体测单位/巴陵石化.ipynb index 227e60e..1263de5 100644 --- a/体测单位/巴陵石化.ipynb +++ b/体测单位/巴陵石化.ipynb @@ -255,12 +255,6 @@ " m_depart = v['unit']\n", " depart.append(m_depart) \n", " dict2[int(k)] = [m_name,m_depart]\n", - "# 创建部门办公室 \n", - "m_path = os.getcwd()+'/file/137/new'\n", - "for pn in depart:\n", - " if not os.path.exists(m_path + '/' + pn):\n", - " os.mkdir(m_path + '/' + pn)\n", - "#print(dict1)\n", "\n", "\n", "fl=os.listdir(fi_path)\n", @@ -272,9 +266,10 @@ "old.sort()\n", " #print(str(nfn)+'.pdf')\n", "\n", - "for n in old:\n", - " \n", + "for n in old: \n", " o_name = f'{fi_path}/{n}.pdf'\n", + " if not os.path.exists(f'{fi_path}/new/{dict2[n][1]}'):\n", + " os.mkdir(f'{fi_path}/new/{dict2[n][1]}') \n", " n_name = f'{fi_path}/new/{dict2[n][1]}/{str(n).rjust(5,\"0\")}-{dict2[n][0]}.pdf'\n", " if not os.path.exists(n_name):\n", " shutil.copyfile(o_name,n_name)\n", @@ -291,16 +286,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "22836727-9658-453a-99db-4d270c3253d4", "metadata": { - "execution": { - "iopub.execute_input": "2022-11-02T03:09:46.184215Z", - "iopub.status.busy": "2022-11-02T03:09:46.183065Z", - "iopub.status.idle": "2022-11-02T03:09:46.407389Z", - "shell.execute_reply": "2022-11-02T03:09:46.404489Z", - "shell.execute_reply.started": "2022-11-02T03:09:46.184107Z" - }, "tags": [] }, "outputs": [], @@ -322,7 +310,7 @@ " list2 = [code.rjust(5,\"0\"),dict1[code]['name'],dict1[code]['unit']]\n", " list1.append(list2)\n", "title = ['编号','姓名','部门'] \n", - "filename = 'data/巴陵十五部门人员体测情况表(截至20221101).xlsx'\n", + "filename = 'data/巴陵二部门人员体测情况表(截至20221103).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -332,10 +320,63 @@ "wb.save(filename)" ] }, + { + "cell_type": "markdown", + "id": "2f392a9a-0ffd-48c2-a9d7-7af99ca0f5f6", + "metadata": {}, + "source": [ + "### 统计部门测试人员情况" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "b5c817af-a77e-4968-9a9e-680675f4a646", + "id": "e8e04af4-978a-463f-83e3-c015e1e72938", + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "title = ['部门','部门人数','已测人数','未测人数']\n", + "filename = 'data/巴陵石化人员.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "filename = 'data/result_巴陵.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", + "\n", + "dict3 = {}\n", + "for k, v in dict1.items():\n", + " dict3.setdefault(v['unit'],{})\n", + " dict3[v['unit']].setdefault('人数',0)\n", + " dict3[v['unit']].setdefault('已测人数',0)\n", + " dict3[v['unit']]['人数'] = dict3[v['unit']]['人数']+1\n", + "for k, v in dict2.items():\n", + " if len(v.keys())>5: \n", + " dict3[v['unit']]['已测人数'] = dict3[v['unit']]['已测人数'] + 1\n", + "list1 = []\n", + "\n", + "for k, v in dict3.items():\n", + " list2 = []\n", + " list2 = [k,v['人数'],v['已测人数'],v['人数']-v['已测人数']]\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)\n", + "print('ok!')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9cfed761-0251-47b5-831b-e005b6675452", "metadata": {}, "outputs": [], "source": []