This commit is contained in:
512song committed 2023-11-03 20:06:25 +08:00
1 parent 5104f4974b
commit 27b50a7301
1 file changed
+91 -7
+91 -7
View File
@@ -1491,7 +1491,6 @@
"cell_type": "markdown",
"id": "73524e7f-4262-46d3-a733-74ac18e43855",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
@@ -2333,6 +2332,91 @@
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "4a075c1b-41d9-4ff5-8f0a-115127e5e155",
"metadata": {},
"source": [
"## 生成体测成绩明细表"
]
},
{
"cell_type": "code",
"execution_count": 201,
"id": "b363792b-cbc6-46a7-b87f-1e122bcb116e",
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-03T11:53:15.355794Z",
"iopub.status.busy": "2023-11-03T11:53:15.355574Z",
"iopub.status.idle": "2023-11-03T11:53:17.167168Z",
"shell.execute_reply": "2023-11-03T11:53:17.166724Z",
"shell.execute_reply.started": "2023-11-03T11:53:15.355779Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
"bmi = ['height','weight']\n",
"title = ['编号','姓名','性别','单位/部门','身高','体重','bmi','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
"\n",
"filename = 'data/result_天津231017.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"list1 = []\n",
"for k, v in dict1.items(): #print(k,dict2[str(k)]['name'])\n",
" list2 = []\n",
" list2.append(str(k).rjust(5,'0'))\n",
" list2.append(dict1[k]['name']) \n",
" list2.append(dict1[k]['sex'])\n",
" list2.append(dict1[k]['unit'])\n",
" i = 0\n",
" if 'bmi' in dict1[k].keys():\n",
" list2.append(dict1[k]['height']['成绩'])\n",
" list2.append(dict1[k]['weight']['成绩'])\n",
" list2.append(dict1[k]['bmi']['score'])\n",
" i+=1\n",
" else:\n",
" list2.append('') \n",
" list2.append('') \n",
" list2.append('') \n",
" \n",
" \n",
" for item in items:\n",
" if item in dict1[k].keys():\n",
" list2.append(dict1[k][item]['成绩'])\n",
" list2.append(dict1[k][item]['score']) \n",
" i+=1\n",
" elif item =='name':\n",
" list2.append(dict1[k][item])\n",
" else:\n",
" list2.append('') \n",
" list2.append('') \n",
" if i>2:\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",
"id": "85a03b00-9624-4ae9-aa6d-386798d457df",
@@ -2360,15 +2444,15 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 198,
"id": "f9fee64f-41ff-4453-8a32-a33df086022e",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:50:48.179535Z",
"iopub.status.busy": "2023-10-25T03:50:48.179245Z",
"iopub.status.idle": "2023-10-25T03:50:48.598995Z",
"shell.execute_reply": "2023-10-25T03:50:48.598421Z",
"shell.execute_reply.started": "2023-10-25T03:50:48.179514Z"
"iopub.execute_input": "2023-11-03T11:30:39.166719Z",
"iopub.status.busy": "2023-11-03T11:30:39.166280Z",
"iopub.status.idle": "2023-11-03T11:30:39.464034Z",
"shell.execute_reply": "2023-11-03T11:30:39.463499Z",
"shell.execute_reply.started": "2023-11-03T11:30:39.166682Z"
},
"tags": []
},