This commit is contained in:
512song@sina.com committed 2022-11-14 19:08:18 +08:00
1 parent 78a0714c22
commit d8a85055f9
1 file changed
+132 -5
+132 -5
View File
@@ -57,12 +57,27 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 21,
"id": "e5e4145b-d575-46b5-a530-c722668f76f3", "id": "e5e4145b-d575-46b5-a530-c722668f76f3",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2022-11-14T10:36:20.132710Z",
"iopub.status.busy": "2022-11-14T10:36:20.132189Z",
"iopub.status.idle": "2022-11-14T10:36:20.745694Z",
"shell.execute_reply": "2022-11-14T10:36:20.744512Z",
"shell.execute_reply.started": "2022-11-14T10:36:20.132662Z"
},
"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",
@@ -107,6 +122,72 @@
"print('ok')" "print('ok')"
] ]
}, },
{
"cell_type": "code",
"execution_count": 22,
"id": "df3ea897-92af-4f4f-9877-9a0b807cfc59",
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-14T10:36:57.086011Z",
"iopub.status.busy": "2022-11-14T10:36:57.085472Z",
"iopub.status.idle": "2022-11-14T10:37:00.597648Z",
"shell.execute_reply": "2022-11-14T10:37:00.596497Z",
"shell.execute_reply.started": "2022-11-14T10:36:57.085962Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','部门','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
"filename = 'data/result_巴陵.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"filename = 'data/巴陵石化人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"\n",
"for k, v in dict2.items():\n",
" #print(k,dict2[str(k)]['name'])\n",
" list2 = []\n",
" list2.append(str(k).rjust(5,'0'))\n",
" list2.append(v['name']) \n",
" list2.append(dict1[k]['sex'])\n",
" list2.append(dict1[k]['unit']) \n",
" if len(v.keys())>5: \n",
" for item in items:\n",
" if item in v.keys():\n",
" list2.append(v[item]['成绩'])\n",
" list2.append(v[item]['得分']) \n",
" elif item =='name':\n",
" list2.append(v[item])\n",
" else:\n",
" list2.append('') \n",
" list2.append('') \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": "markdown", "cell_type": "markdown",
"id": "3c911994-2ce1-4412-8d56-39b195e66457", "id": "3c911994-2ce1-4412-8d56-39b195e66457",
@@ -440,18 +521,64 @@
"print('ok!')" "print('ok!')"
] ]
}, },
{
"cell_type": "markdown",
"id": "fa9473fc-8e1c-4883-b919-6c5215f7b932",
"metadata": {},
"source": [
"### 统计有成绩无得分人员"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "9cfed761-0251-47b5-831b-e005b6675452", "id": "cf17511f-9932-4191-9dae-d345e26ddf0d",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','部门','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
"filename = 'data/result_巴陵.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"filename = 'data/巴陵石化人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"\n",
"for k, v in dict2.items():\n",
" #print(k,dict2[str(k)]['name'])\n",
" list2 = []\n",
" list2.append(str(k).rjust(5,'0'))\n",
" list2.append(v['name']) \n",
" list2.append(dict1[k]['sex'])\n",
" list2.append(dict1[k]['unit']) \n",
" if len(v.keys())>5: \n",
" for item in items:\n",
" if item in v.keys() and v[item]['得分'] = '\\N':\n",
" \n",
" list2.append(v[item]['成绩'])\n",
" list2.append(v[item]['得分']) \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') "
]
} }
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },