diff --git a/体质检测管理.ipynb b/体质检测管理.ipynb index ca94985..7eacde1 100644 --- a/体质检测管理.ipynb +++ b/体质检测管理.ipynb @@ -787,6 +787,72 @@ "#print(type(x))" ] }, + { + "cell_type": "markdown", + "id": "4d255389-bc5c-4251-861e-3a4d65bf5c26", + "metadata": {}, + "source": [ + "## 根据体测报告生成分组表" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "ed6b40e9-4c5f-4d1f-8810-9f519a8755b0", + "metadata": { + "execution": { + "iopub.execute_input": "2021-12-21T14:57:58.154705Z", + "iopub.status.busy": "2021-12-21T14:57:58.153424Z", + "iopub.status.idle": "2021-12-21T14:57:59.771235Z", + "shell.execute_reply": "2021-12-21T14:57:59.767942Z", + "shell.execute_reply.started": "2021-12-21T14:57:58.154596Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import openpyxl\n", + "import json\n", + "import os,sys,shutil\n", + "import glob\n", + "\n", + "fl=glob.glob('./file/211130/*.pdf')\n", + "list1 = []\n", + "for fi in fl:\n", + " s = os.path.basename(fi).split('.')[0]\n", + " list1.append(int(s))\n", + "list1.sort()\n", + "#print(list1)\n", + "wb = openpyxl.load_workbook('data/济南炼化.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "depart = []\n", + "dict1 = {}\n", + "new_code = []\n", + "for n in range(2, sheet.max_row+1):\n", + " m_depart = sheet.cell(n,5).value\n", + " dict2 = {}\n", + " dict1.setdefault(m_depart,[])\n", + " dict2[sheet.cell(n,1).value] = sheet.cell(n,2).value\n", + " dict1[m_depart].append(dict2)\n", + "wb = openpyxl.Workbook()\n", + "\n", + "sheet = wb.active\n", + "i = 1\n", + "\n", + "for k , v in dict1.items():\n", + " sheet[f'A{i}'] = k\n", + " i += 1\n", + " for item in v:\n", + " for k1, v1 in item.items():\n", + " if k1 in list1:\n", + " sheet[f'A{i}'] = str(k1).rjust(5,\"0\")\n", + " sheet[f'B{i}'] = v1\n", + " i += 1\n", + "wb.save('./data/济南炼化体测报告部门明细表.xlsx')\n", + "#print(dict1)\n" + ] + }, { "cell_type": "markdown", "id": "c67fc14e-ccf8-41c5-a0f8-0c3a664eb484", diff --git a/文件管理1.ipynb b/文件管理1.ipynb index 797d093..0f14f8c 100755 --- a/文件管理1.ipynb +++ b/文件管理1.ipynb @@ -742,7 +742,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -756,7 +756,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.1" + "version": "3.8.10" } }, "nbformat": 4,