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)"
|
" 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",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "22e1e0cf-5620-47d4-8034-03149fcd0b00",
|
"id": "34876192-a7d3-454d-a929-53e3b6bfbeae",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
+14
-44
@@ -120,15 +120,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": 1,
|
||||||
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2023-11-26T12:31:39.094899Z",
|
"iopub.execute_input": "2024-05-06T04:04:00.891103Z",
|
||||||
"iopub.status.busy": "2023-11-26T12:31:39.094370Z",
|
"iopub.status.busy": "2024-05-06T04:04:00.890635Z",
|
||||||
"iopub.status.idle": "2023-11-26T12:31:39.114981Z",
|
"iopub.status.idle": "2024-05-06T04:04:00.919838Z",
|
||||||
"shell.execute_reply": "2023-11-26T12:31:39.114071Z",
|
"shell.execute_reply": "2024-05-06T04:04:00.918845Z",
|
||||||
"shell.execute_reply.started": "2023-11-26T12:31:39.094860Z"
|
"shell.execute_reply.started": "2024-05-06T04:04:00.891065Z"
|
||||||
},
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
@@ -137,8 +137,8 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"16\n",
|
"41\n",
|
||||||
"16\n"
|
"41\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -157,11 +157,11 @@
|
|||||||
"re_ta = {}\n",
|
"re_ta = {}\n",
|
||||||
"dict1 = {}\n",
|
"dict1 = {}\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"filename = 'data/北京党校.json'\n",
|
"filename = 'data/青海.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/places_result_20231126.csv'\n",
|
"filename = 'data/places_result_20240311.csv'\n",
|
||||||
"with open(filename,'r',newline='') as csv_file:\n",
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
" header = next(fl) \n",
|
" header = next(fl) \n",
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||||||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||||
"print(len(re_ta))\n",
|
"print(len(re_ta))\n",
|
||||||
"filename = 'data/result_北京党校20231126.json'\n",
|
"filename = 'data/result_青海20240311.json'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||||
@@ -212,11 +212,11 @@
|
|||||||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/result_北京党校.json'\n",
|
"filename = 'data/result_青海20240311.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl)\n",
|
" dict1 = json.load(fl)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/北京党校.json'\n",
|
"filename = 'data/青海.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict2 = json.load(fl)\n",
|
" dict2 = json.load(fl)\n",
|
||||||
" \n",
|
" \n",
|
||||||
@@ -235,7 +235,7 @@
|
|||||||
" else:\n",
|
" else:\n",
|
||||||
" list2.append('') \n",
|
" list2.append('') \n",
|
||||||
" list1.append(list2)\n",
|
" list1.append(list2)\n",
|
||||||
"filename = 'data/北京党校.xlsx'\n",
|
"filename = 'data/青海20240311.xlsx'\n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"sheet.append(title)\n",
|
"sheet.append(title)\n",
|
||||||
@@ -253,36 +253,6 @@
|
|||||||
"## 手工数据导入数据库"
|
"## 手工数据导入数据库"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
|
|
||||||
"metadata": {
|
|
||||||
"tags": []
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"import openpyxl\n",
|
|
||||||
"import json\n",
|
|
||||||
"\n",
|
|
||||||
"filename = 'data/北京党校.json'\n",
|
|
||||||
"with open(filename,'r') as fl:\n",
|
|
||||||
" dict2 = json.load(fl)\n",
|
|
||||||
"wb = openpyxl.load_workbook('data/北京党校手工数据.xlsx')\n",
|
|
||||||
"sheet = wb.active\n",
|
|
||||||
"# sheets = wb.sheetnames\n",
|
|
||||||
"dict1 = {}\n",
|
|
||||||
"dict3 = {1:10,2:11,3:7,4:2,5:6,6:3,7:1}\n",
|
|
||||||
"sheet = wb.active\n",
|
|
||||||
"data1 =list(sheet.values)\n",
|
|
||||||
"del data1[0]\n",
|
|
||||||
"list1 = []\n",
|
|
||||||
"for item in data1:\n",
|
|
||||||
" code = int(item[0])\n",
|
|
||||||
" list1.append((496534,code,item[2],item[1],'2023-10-15','2023-10-15 14:00:00'))\n",
|
|
||||||
"print(list1)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
Reference in new issue
Block a user