20221102
This commit is contained in:
1 parent
8542f74bd0
commit
5eb7a1513d
2 files changed
+417
-76
No files matched your search
+95
-76
@@ -10,27 +10,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 22,
|
"execution_count": null,
|
||||||
"id": "f6bc68b5-9ed8-4b28-ab1a-452107b6429a",
|
"id": "f6bc68b5-9ed8-4b28-ab1a-452107b6429a",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2022-10-26T11:58:59.214911Z",
|
|
||||||
"iopub.status.busy": "2022-10-26T11:58:59.214385Z",
|
|
||||||
"iopub.status.idle": "2022-10-26T11:59:00.200796Z",
|
|
||||||
"shell.execute_reply": "2022-10-26T11:59:00.199708Z",
|
|
||||||
"shell.execute_reply.started": "2022-10-26T11:58:59.214863Z"
|
|
||||||
},
|
|
||||||
"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,15 +57,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 29,
|
"execution_count": 17,
|
||||||
"id": "97031317-76ed-4404-b922-6ca749e4fd2a",
|
"id": "97031317-76ed-4404-b922-6ca749e4fd2a",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2022-10-26T15:13:05.551848Z",
|
"iopub.execute_input": "2022-11-01T09:18:38.933088Z",
|
||||||
"iopub.status.busy": "2022-10-26T15:13:05.551291Z",
|
"iopub.status.busy": "2022-11-01T09:18:38.932552Z",
|
||||||
"iopub.status.idle": "2022-10-26T15:13:05.733924Z",
|
"iopub.status.idle": "2022-11-01T09:18:39.012745Z",
|
||||||
"shell.execute_reply": "2022-10-26T15:13:05.732766Z",
|
"shell.execute_reply": "2022-11-01T09:18:39.011599Z",
|
||||||
"shell.execute_reply.started": "2022-10-26T15:13:05.551800Z"
|
"shell.execute_reply.started": "2022-11-01T09:18:38.933039Z"
|
||||||
},
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
@@ -147,15 +132,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 30,
|
"execution_count": 18,
|
||||||
"id": "f70a02f2-934e-43ed-93ff-b34cb732dfc6",
|
"id": "f70a02f2-934e-43ed-93ff-b34cb732dfc6",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2022-10-26T15:13:15.553588Z",
|
"iopub.execute_input": "2022-11-01T09:18:42.502192Z",
|
||||||
"iopub.status.busy": "2022-10-26T15:13:15.553050Z",
|
"iopub.status.busy": "2022-11-01T09:18:42.501603Z",
|
||||||
"iopub.status.idle": "2022-10-26T15:13:15.663507Z",
|
"iopub.status.idle": "2022-11-01T09:18:42.729776Z",
|
||||||
"shell.execute_reply": "2022-10-26T15:13:15.662380Z",
|
"shell.execute_reply": "2022-11-01T09:18:42.728671Z",
|
||||||
"shell.execute_reply.started": "2022-10-26T15:13:15.553540Z"
|
"shell.execute_reply.started": "2022-11-01T09:18:42.502143Z"
|
||||||
},
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
@@ -190,7 +175,7 @@
|
|||||||
" else:\n",
|
" else:\n",
|
||||||
" list2.append('') \n",
|
" list2.append('') \n",
|
||||||
" list1.append(list2)\n",
|
" list1.append(list2)\n",
|
||||||
"filename = 'data/北海炼化体测情况表(截至20221026).xlsx'\n",
|
"filename = 'data/北海炼化体测情况表(截至20221101).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",
|
||||||
@@ -200,6 +185,76 @@
|
|||||||
"wb.save(filename)"
|
"wb.save(filename)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "84325f89-1408-4d0a-b877-f4b54bcb22ce",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 统计部门测试人员情况"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 24,
|
||||||
|
"id": "c42c5c04-49f3-4b4c-8f77-e37cfa9748f2",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2022-11-01T09:27:40.105525Z",
|
||||||
|
"iopub.status.busy": "2022-11-01T09:27:40.104998Z",
|
||||||
|
"iopub.status.idle": "2022-11-01T09:27:40.151243Z",
|
||||||
|
"shell.execute_reply": "2022-11-01T09:27:40.150059Z",
|
||||||
|
"shell.execute_reply.started": "2022-11-01T09:27:40.105476Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok!\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"title = ['部门','部门人数','已测人数','未测人数']\n",
|
||||||
|
"filename = 'data/北海炼化人员_2022.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"filename = 'data/result_北海炼化2022.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" dict3.setdefault(v['unit'],{})\n",
|
||||||
|
" dict3[v['unit']].setdefault('人数',0)\n",
|
||||||
|
" dict3[v['unit']].setdefault('已测人数',0)\n",
|
||||||
|
" dict3[v['unit']]['人数'] = dict3[v['unit']]['人数']+1\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" if len(v.keys())>5: \n",
|
||||||
|
" dict3[v['unit']]['已测人数'] = dict3[v['unit']]['已测人数'] + 1\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in dict3.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" list2 = [k,v['人数'],v['已测人数'],v['人数']-v['已测人数']]\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!')"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "5ec595eb-f979-425e-b7eb-9af094ffb43d",
|
"id": "5ec595eb-f979-425e-b7eb-9af094ffb43d",
|
||||||
@@ -210,15 +265,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 23,
|
"execution_count": 8,
|
||||||
"id": "a9460ee7-1f60-4a3b-a45d-8a1dba04b920",
|
"id": "a9460ee7-1f60-4a3b-a45d-8a1dba04b920",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2022-10-26T11:59:11.407159Z",
|
"iopub.execute_input": "2022-10-31T11:54:40.324705Z",
|
||||||
"iopub.status.busy": "2022-10-26T11:59:11.406624Z",
|
"iopub.status.busy": "2022-10-31T11:54:40.324184Z",
|
||||||
"iopub.status.idle": "2022-10-26T11:59:11.664219Z",
|
"iopub.status.idle": "2022-10-31T11:54:40.626097Z",
|
||||||
"shell.execute_reply": "2022-10-26T11:59:11.663061Z",
|
"shell.execute_reply": "2022-10-31T11:54:40.624830Z",
|
||||||
"shell.execute_reply.started": "2022-10-26T11:59:11.407111Z"
|
"shell.execute_reply.started": "2022-10-31T11:54:40.324656Z"
|
||||||
},
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
@@ -255,7 +310,7 @@
|
|||||||
" \n",
|
" \n",
|
||||||
"filename = 'data/北海炼化人员_2022.json'\n",
|
"filename = 'data/北海炼化人员_2022.json'\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(dict1, fl) \n",
|
" json.dump(dict1, fl, ensure_ascii=False) \n",
|
||||||
"print('ok')"
|
"print('ok')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -269,41 +324,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 24,
|
"execution_count": null,
|
||||||
"id": "61fbd157-f4f0-4c85-98dc-0e79ee99280b",
|
"id": "61fbd157-f4f0-4c85-98dc-0e79ee99280b",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2022-10-26T11:59:14.395184Z",
|
|
||||||
"iopub.status.busy": "2022-10-26T11:59:14.394650Z",
|
|
||||||
"iopub.status.idle": "2022-10-26T11:59:14.567363Z",
|
|
||||||
"shell.execute_reply": "2022-10-26T11:59:14.566447Z",
|
|
||||||
"shell.execute_reply.started": "2022-10-26T11:59:14.395136Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"00068 张利雄 1987-09-24\n",
|
|
||||||
"00120 黎秀珍 1966-12-22\n",
|
|
||||||
"00259 彭秋丽 1989-08-15\n",
|
|
||||||
"00348 黄宏州 1995-02-19\n",
|
|
||||||
"00424 易华锋 1985-12-02\n",
|
|
||||||
"00524 周爱娟 1971-10-11\n",
|
|
||||||
"00525 马遥碧 1971-06-13\n",
|
|
||||||
"00534 潘永远 1962-03-24\n",
|
|
||||||
"00614 刘文涛 1997-07-13\n",
|
|
||||||
"00689 陈雪 1966-11-14\n",
|
|
||||||
"00725 冯剑秋 1972-01-07\n",
|
|
||||||
"00727 汪纯燕 1971-12-06\n",
|
|
||||||
"00733 曾媛 1972-07-14\n",
|
|
||||||
"00758 谭志坚 1972-04-02\n",
|
|
||||||
"00798 冯鸥 1992-11-24\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
@@ -344,16 +370,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 28,
|
"execution_count": null,
|
||||||
"id": "d3ca4d45-6a83-4d50-8419-cf8aa9b3aa4c",
|
"id": "d3ca4d45-6a83-4d50-8419-cf8aa9b3aa4c",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2022-10-26T12:11:23.788353Z",
|
|
||||||
"iopub.status.busy": "2022-10-26T12:11:23.787816Z",
|
|
||||||
"iopub.status.idle": "2022-10-26T12:11:23.836530Z",
|
|
||||||
"shell.execute_reply": "2022-10-26T12:11:23.835397Z",
|
|
||||||
"shell.execute_reply.started": "2022-10-26T12:11:23.788303Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
|
|||||||
+322
@@ -0,0 +1,322 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "37eee6b1-ddbc-414c-ac74-e831c53c9bdb",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 人员基本信息导入"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "a27e986c-0c40-4792-b24d-03b19df707a9",
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/巴陵石化监测花名册.xlsx')\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"person = {}\n",
|
||||||
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
|
" if sheet.cell(n,2).value is None:\n",
|
||||||
|
" break\n",
|
||||||
|
" else: \n",
|
||||||
|
" code = int(sheet.cell(n, 4).value)\n",
|
||||||
|
" person.setdefault(code, {})\n",
|
||||||
|
" dict1 = {}\n",
|
||||||
|
" dict1['name'] = sheet.cell(n, 6).value \n",
|
||||||
|
" xb = str(sheet.cell(n, 7).value)\n",
|
||||||
|
" if xb == '1':\n",
|
||||||
|
" sex = '男'\n",
|
||||||
|
" elif xb =='2':\n",
|
||||||
|
" sex = '女'\n",
|
||||||
|
" dict1['sex'] = sex\n",
|
||||||
|
" dict1['unit'] = sheet.cell(n, 3).value\n",
|
||||||
|
" dict1['birth'] = str(sheet.cell(n,8).value).split(' ')[0]\n",
|
||||||
|
" person[code] = dict1\n",
|
||||||
|
"filename = 'data/巴陵石化人员.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "b1384a8f-36f4-483e-afb4-65a56a064dd3",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 获取人员测试成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "e5e4145b-d575-46b5-a530-c722668f76f3",
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import time\n",
|
||||||
|
"import csv\n",
|
||||||
|
"\n",
|
||||||
|
"filename = '../item.json'\n",
|
||||||
|
"item = {}\n",
|
||||||
|
"unit = {}\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"for k,v in dict1.items():\n",
|
||||||
|
" item[k] = v\n",
|
||||||
|
"#SQL语句为:\n",
|
||||||
|
"# SELECT a.item_id,a.performance,a.score,a.date AS DATE1,a.avatar_id,b.unit,b.name FROM places_result AS a,_zgshhgxs AS b WHERE a.place_id=135 AND a.avatar_id=b.id AND a.avatar_id < 4999\n",
|
||||||
|
"\n",
|
||||||
|
"re_ta = {}\n",
|
||||||
|
"dict1 = {}\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"#print(\"\\n运动项目信息:\")\n",
|
||||||
|
"filename = 'data/137_2210.csv'\n",
|
||||||
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
|
" header = next(fl) \n",
|
||||||
|
" for line in fl:\n",
|
||||||
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||||||
|
" list1.append(line)\n",
|
||||||
|
"#print(list1)\n",
|
||||||
|
"for result in list1:\n",
|
||||||
|
" user = str(result[4])\n",
|
||||||
|
" m_item = str(result[0]) \n",
|
||||||
|
" re_ta.setdefault(user,{}) \n",
|
||||||
|
" re_ta[user]['name'] = str(result[6])\n",
|
||||||
|
" re_ta[user]['unit'] = str(result[5]) \n",
|
||||||
|
" item_name = item[m_item]['name']\n",
|
||||||
|
" re_ta[user].setdefault(item_name,{}) \n",
|
||||||
|
" score = int(result[1])/item[m_item]['divisor'] \n",
|
||||||
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||||
|
" re_ta[user][item_name]['得分'] =result[2]\n",
|
||||||
|
"filename = 'data/result_巴陵.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(re_ta, fl) \n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "3c911994-2ce1-4412-8d56-39b195e66457",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 导出测试成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "0582bc84-7234-415f-9715-66c27b6b8f91",
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"title = ['编号','姓名','性别','单位/部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"filename = 'data/result_巴陵.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/巴陵石化人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
" \n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" list2.append(str(k).rjust(8,'0'))\n",
|
||||||
|
" list2.append(v['name']) \n",
|
||||||
|
" list2.append(dict2[k]['sex'])\n",
|
||||||
|
" list2.append(dict2[k]['unit']) \n",
|
||||||
|
" \n",
|
||||||
|
" for item in items:\n",
|
||||||
|
" if item in v.keys():\n",
|
||||||
|
" list2.append(v[item]['成绩']) \n",
|
||||||
|
" elif item =='name':\n",
|
||||||
|
" list2.append(v[item])\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('') \n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"filename = 'data/巴陵石化体测情况表(截至20221031).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": "markdown",
|
||||||
|
"id": "8e8dc85d-7ed7-4146-98c6-8d2dc64026ea",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 统计测试成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 33,
|
||||||
|
"id": "6b40ff7f-68c1-4c04-9bdc-3af16980fc25",
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
"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": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"title = ['编号','姓名','性别','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
||||||
|
"filename = 'data/result_巴陵.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/巴陵石化人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
" \n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" sex = dict2[k]['sex']\n",
|
||||||
|
" dict3.setdefault(sex,{}) \n",
|
||||||
|
" for item in v.keys():\n",
|
||||||
|
" if item in items:\n",
|
||||||
|
" dict3[sex].setdefault(item,[]) \n",
|
||||||
|
" if v[item]['得分'].isdigit() :\n",
|
||||||
|
" dict3[sex][item].append(v[item]['得分']) \n",
|
||||||
|
"#print(dict3) \n",
|
||||||
|
"for k, v in dict3.items():\n",
|
||||||
|
" sex = k\n",
|
||||||
|
" for k1, v1 in v.items():\n",
|
||||||
|
" df = 0\n",
|
||||||
|
" if len(v1) >0:\n",
|
||||||
|
" \n",
|
||||||
|
" for i in range(0,len(v1)-1):\n",
|
||||||
|
" df = df + int(v1[i])\n",
|
||||||
|
" print(sex,k1,df,i)\n",
|
||||||
|
" \n",
|
||||||
|
" \n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "4788ee4a-5b78-48ed-bfbf-dbf780baf569",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.8.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
Reference in new issue
Block a user