From 8b780a6e669c0dc92dfee9597b635de8bfadffc2 Mon Sep 17 00:00:00 2001 From: 512song Date: Tue, 26 Oct 2021 22:03:56 +0800 Subject: [PATCH] 20211026 --- 体质检测管理.ipynb | 76 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/体质检测管理.ipynb b/体质检测管理.ipynb index b903880..9fd7221 100644 --- a/体质检测管理.ipynb +++ b/体质检测管理.ipynb @@ -752,12 +752,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "9e33d1bc-1b71-47f7-928a-16ec435449d6", "metadata": { + "execution": { + "iopub.execute_input": "2021-10-26T08:21:04.983764Z", + "iopub.status.busy": "2021-10-26T08:21:04.982673Z", + "iopub.status.idle": "2021-10-26T08:21:09.421348Z", + "shell.execute_reply": "2021-10-26T08:21:09.419179Z", + "shell.execute_reply.started": "2021-10-26T08:21:04.983506Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], "source": [ "import openpyxl\n", "import json\n", @@ -790,10 +805,65 @@ "print('ok')" ] }, + { + "cell_type": "markdown", + "id": "f9e61ba9-38f8-4b61-bf1e-4e7bbde4f32c", + "metadata": {}, + "source": [ + "## 心理健康量表统计导入" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "2475a1c3-c2e7-45d6-9685-32e28e606df5", + "metadata": { + "execution": { + "iopub.execute_input": "2021-10-26T13:02:51.590980Z", + "iopub.status.busy": "2021-10-26T13:02:51.590050Z", + "iopub.status.idle": "2021-10-26T13:02:52.262203Z", + "shell.execute_reply": "2021-10-26T13:02:52.260218Z", + "shell.execute_reply.started": "2021-10-26T13:02:51.590874Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "wb = openpyxl.load_workbook('file/北海炼化公司职工心理健康量表统计.xlsx')\n", + "sheet = wb.active\n", + "#sheets = wb.sheetnames\n", + "dict1 = {}\n", + "for n in range(2,sheet.max_row+1):\n", + " mdm = sheet.cell(n,1).value\n", + " dict1.setdefault(mdm,{})\n", + " dict2 = {}\n", + " list1 = [1,2,3,4,5,None]\n", + " for i in range(2,42):\n", + " #if sheet.cell(n,i).value not in list1:\n", + " dict2[i-1] = sheet.cell(n,i).value\n", + " #print(f'error!{mdm}--{sheet.cell(n,i).value}')\n", + " dict1[mdm] = dict2\n", + "filename = '北海炼化公司职工心理健康量表统计.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl,ensure_ascii=False) \n", + "print('ok')" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "607638c1-9cfe-442a-9823-3b506ce04db6", + "id": "671d6afe-5ed2-404e-bd8c-df3118ea3743", "metadata": {}, "outputs": [], "source": []