20240506
This commit is contained in:
1 parent
fc007608ca
commit
fcaecfd995
2 files changed
+169
-45
No files matched your search
+155
-1
@@ -1293,10 +1293,164 @@
|
||||
" print(item)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3be7547a-f705-46cc-94e1-37c83ee04d86",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 生成体测成绩表"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "f671a493-88a7-4594-98d7-bd3d0a091bee",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-04-30T03:36:18.290034Z",
|
||||
"iopub.status.busy": "2024-04-30T03:36:18.289557Z",
|
||||
"iopub.status.idle": "2024-04-30T03:36:18.352150Z",
|
||||
"shell.execute_reply": "2024-04-30T03:36:18.350627Z",
|
||||
"shell.execute_reply.started": "2024-04-30T03:36:18.289994Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "KeyError",
|
||||
"evalue": "'sex'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[0;32mIn[6], line 17\u001b[0m\n\u001b[1;32m 15\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;28mstr\u001b[39m(k)\u001b[38;5;241m.\u001b[39mrjust(\u001b[38;5;241m5\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m0\u001b[39m\u001b[38;5;124m'\u001b[39m))\n\u001b[1;32m 16\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(dict1[k][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m]) \n\u001b[0;32m---> 17\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(\u001b[43mdict1\u001b[49m\u001b[43m[\u001b[49m\u001b[43mk\u001b[49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msex\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m)\n\u001b[1;32m 18\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(dict1[k][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m部门\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[1;32m 19\u001b[0m i \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n",
|
||||
"\u001b[0;31mKeyError\u001b[0m: 'sex'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['身高','体重','肺活量','握力','纵跳','坐位体前屈','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"bmi = ['height','weight']\n",
|
||||
"title = ['编号','姓名','性别','单位/部门','身高','','体重','','肺活量','','握力','','纵跳','','坐位体前屈','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数','']\n",
|
||||
"\n",
|
||||
"filename = 'data/result_杨庙2308.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]['部门'])\n",
|
||||
" i = 0\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]['得分']) \n",
|
||||
" i+=1\n",
|
||||
" elif item =='name':\n",
|
||||
" list2.append(dict1[k][item])\n",
|
||||
" else:\n",
|
||||
" list2.append('') \n",
|
||||
" list2.append('')\n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/杨庙202303体测明细表.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": "code",
|
||||
"execution_count": 9,
|
||||
"id": "ffce0b6c-5fcd-40b5-a118-6ae2ce9ec464",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-04-30T03:52:18.063321Z",
|
||||
"iopub.status.busy": "2024-04-30T03:52:18.062912Z",
|
||||
"iopub.status.idle": "2024-04-30T03:52:18.197236Z",
|
||||
"shell.execute_reply": "2024-04-30T03:52:18.196723Z",
|
||||
"shell.execute_reply.started": "2024-04-30T03:52:18.063266Z"
|
||||
},
|
||||
"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_杨庙2308.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\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]['gender'])\n",
|
||||
" list2.append(dict1[k]['title'])\n",
|
||||
" i = 0\n",
|
||||
" if 'bmi' in v['fit'].keys():\n",
|
||||
" m_bmi = v['fit']['bmi']['mark']\n",
|
||||
" list2.append(m_bmi.split(',')[0])\n",
|
||||
" list2.append(m_bmi.split(',')[1])\n",
|
||||
" list2.append(v['fit']['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 v['fit'].keys():\n",
|
||||
" list2.append(v['fit'][item]['mark'])\n",
|
||||
" list2.append(v['fit'][item]['score']) \n",
|
||||
" i+=1\n",
|
||||
" \n",
|
||||
" else:\n",
|
||||
" list2.append('') \n",
|
||||
" list2.append('') \n",
|
||||
" \n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/杨庙202308体测明细表.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": "code",
|
||||
"execution_count": null,
|
||||
"id": "22e1e0cf-5620-47d4-8034-03149fcd0b00",
|
||||
"id": "34876192-a7d3-454d-a929-53e3b6bfbeae",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user