This commit is contained in:
512song committed 2022-11-02 11:41:38 +08:00
1 parent 5eb7a1513d
commit b0635ee408
1 file changed
+123 -80
+123 -80
View File
@@ -10,27 +10,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"id": "a27e986c-0c40-4792-b24d-03b19df707a9", "id": "a27e986c-0c40-4792-b24d-03b19df707a9",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2022-10-31T13:50:14.056581Z",
"iopub.status.busy": "2022-10-31T13:50:14.055983Z",
"iopub.status.idle": "2022-10-31T13:50:15.632245Z",
"shell.execute_reply": "2022-10-31T13:50:15.630795Z",
"shell.execute_reply.started": "2022-10-31T13:50:14.056464Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import openpyxl\n", "import openpyxl\n",
"import json\n", "import json\n",
@@ -72,27 +57,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"id": "e5e4145b-d575-46b5-a530-c722668f76f3", "id": "e5e4145b-d575-46b5-a530-c722668f76f3",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2022-10-31T13:54:54.428022Z",
"iopub.status.busy": "2022-10-31T13:54:54.427379Z",
"iopub.status.idle": "2022-10-31T13:54:54.840785Z",
"shell.execute_reply": "2022-10-31T13:54:54.839677Z",
"shell.execute_reply.started": "2022-10-31T13:54:54.427973Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import time\n", "import time\n",
@@ -147,16 +117,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"id": "0582bc84-7234-415f-9715-66c27b6b8f91", "id": "0582bc84-7234-415f-9715-66c27b6b8f91",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2022-10-31T13:55:58.223912Z",
"iopub.status.busy": "2022-10-31T13:55:58.223359Z",
"iopub.status.idle": "2022-10-31T13:55:59.450036Z",
"shell.execute_reply": "2022-10-31T13:55:59.448892Z",
"shell.execute_reply.started": "2022-10-31T13:55:58.223865Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
@@ -210,46 +173,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 33, "execution_count": null,
"id": "6b40ff7f-68c1-4c04-9bdc-3af16980fc25", "id": "6b40ff7f-68c1-4c04-9bdc-3af16980fc25",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T07:59:39.080864Z",
"iopub.status.busy": "2022-10-22T07:59:39.080347Z",
"iopub.status.idle": "2022-10-22T07:59:39.176961Z",
"shell.execute_reply": "2022-10-22T07:59:39.176140Z",
"shell.execute_reply.started": "2022-10-22T07:59:39.080817Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"女 体重 2262 515\n",
"女 肺活量 1455 513\n",
"女 握力 1016 515\n",
"女 单脚站立 1389 513\n",
"女 纵跳 1324 510\n",
"女 一分钟仰卧起坐 1733 442\n",
"女 选择反应时 1667 509\n",
"女 坐位体前屈 1682 499\n",
"女 俯卧撑 0 499\n",
"女 台阶指数 1158 457\n",
"男 体重 4031 1114\n",
"男 肺活量 2967 1114\n",
"男 握力 2174 1118\n",
"男 单脚站立 2257 1096\n",
"男 纵跳 2426 1097\n",
"男 坐位体前屈 3310 1085\n",
"男 选择反应时 3714 1112\n",
"男 台阶指数 2282 949\n",
"男 俯卧撑 3192 1084\n",
"男 一分钟仰卧起坐 0 1084\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import openpyxl\n", "import openpyxl\n",
@@ -289,10 +218,124 @@
" \n" " \n"
] ]
}, },
{
"cell_type": "markdown",
"id": "19947e33-64f8-4855-8b28-60e2a8c3543c",
"metadata": {},
"source": [
"### 报告按照部门分组"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "4788ee4a-5b78-48ed-bfbf-dbf780baf569", "id": "7930c77b-7a99-4bd0-b998-b9801ed3b257",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os,sys,shutil\n",
"import json\n",
"import math\n",
"\n",
"\n",
"fi_path = os.getcwd()+'/file/137'\n",
"old = []\n",
"new = []\n",
"dict2 = {}\n",
"depart = []\n",
"\n",
"filename = 'data/巴陵石化人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"for k, v in dict1.items():\n",
" m_name = v['name']\n",
" 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",
"for fn in fl:\n",
" if os.path.isfile(fi_path + '/' + fn):\n",
" ofn = int(fn.split('.')[0])\n",
" old.append(ofn)\n",
" #print(fn)\n",
"old.sort()\n",
" #print(str(nfn)+'.pdf')\n",
"\n",
"for n in old:\n",
" \n",
" o_name = f'{fi_path}/{n}.pdf'\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",
" print(n_name)"
]
},
{
"cell_type": "markdown",
"id": "b09a3236-e540-4a49-bd19-e11e3de77a71",
"metadata": {},
"source": [
"### 统计报告人员信息表"
]
},
{
"cell_type": "code",
"execution_count": 12,
"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": [],
"source": [
"import json\n",
"import openpyxl\n",
"import os\n",
"import glob\n",
"\n",
"filename = 'data/巴陵石化人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"m_path = os.getcwd()+'/file/137'\n",
"fls = glob.glob(f'file/137/*.pdf')\n",
"list1 = []\n",
"for fn in fls:\n",
" list2 = []\n",
" code = os.path.basename(fn).split('.')[0]\n",
" list2 = [code.rjust(5,\"0\"),dict1[code]['name'],dict1[code]['unit']]\n",
" list1.append(list2)\n",
"title = ['编号','姓名','部门'] \n",
"filename = 'data/巴陵十五部门人员体测情况表(截至20221101).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": "code",
"execution_count": null,
"id": "b5c817af-a77e-4968-9a9e-680675f4a646",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
@@ -300,7 +343,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3 (ipykernel)",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },