This commit is contained in:
512song committed 2024-12-11 18:57:54 +08:00
1 parent 1da757e355
commit 82372feb99
3 files changed
+512 -51

No files matched your search

+406 -24
View File
@@ -2309,15 +2309,15 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 24,
"id": "610b20f3-9fd8-46fc-b8ee-d48c4c854289",
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-08T07:09:49.763833Z",
"iopub.status.busy": "2024-07-08T07:09:49.763076Z",
"iopub.status.idle": "2024-07-08T07:09:49.792041Z",
"shell.execute_reply": "2024-07-08T07:09:49.791388Z",
"shell.execute_reply.started": "2024-07-08T07:09:49.763760Z"
"iopub.execute_input": "2024-12-09T09:22:38.802119Z",
"iopub.status.busy": "2024-12-09T09:22:38.801372Z",
"iopub.status.idle": "2024-12-09T09:22:38.835995Z",
"shell.execute_reply": "2024-12-09T09:22:38.835477Z",
"shell.execute_reply.started": "2024-12-09T09:22:38.802047Z"
}
},
"outputs": [
@@ -2350,6 +2350,8 @@
" dict1['birth'] = birth\n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" person[code] = dict1\n",
"del person[1]\n",
"del person[2]\n",
"filename = 'data/湖南石化青年体质检测.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
@@ -2414,15 +2416,15 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 26,
"id": "1e2d586e-6ff5-4fd1-a909-278d23e54561",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-06T06:27:42.919559Z",
"iopub.status.busy": "2024-12-06T06:27:42.918788Z",
"iopub.status.idle": "2024-12-06T06:27:42.945858Z",
"shell.execute_reply": "2024-12-06T06:27:42.945012Z",
"shell.execute_reply.started": "2024-12-06T06:27:42.919489Z"
"iopub.execute_input": "2024-12-09T09:26:07.189575Z",
"iopub.status.busy": "2024-12-09T09:26:07.187969Z",
"iopub.status.idle": "2024-12-09T09:26:07.219642Z",
"shell.execute_reply": "2024-12-09T09:26:07.219013Z",
"shell.execute_reply.started": "2024-12-09T09:26:07.189495Z"
}
},
"outputs": [
@@ -2430,8 +2432,78 @@
"name": "stdout",
"output_type": "stream",
"text": [
"80\n",
"80\n"
"207\n",
"207\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = '../item1.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",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/长炼医院人员2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20241205-1.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[2])\n",
" if user in dict1.keys(): \n",
" m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n",
"filename = 'data/result_长炼医院人员2024.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "0cad0490-5199-4ca3-bf6f-a206829d702e",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T06:57:46.853287Z",
"iopub.status.busy": "2024-12-11T06:57:46.852519Z",
"iopub.status.idle": "2024-12-11T06:57:46.874391Z",
"shell.execute_reply": "2024-12-11T06:57:46.873811Z",
"shell.execute_reply.started": "2024-12-11T06:57:46.853199Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"78\n",
"78\n"
]
}
],
@@ -2475,7 +2547,112 @@
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n",
"filename = 'data/result_长炼医院人员2024.json'\n",
"filename = 'data/result_长炼医院人员2024(湖南青年).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "dd681c34-dba9-434b-9cd3-ed12fefcce0f",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T07:10:57.109817Z",
"iopub.status.busy": "2024-12-11T07:10:57.109051Z",
"iopub.status.idle": "2024-12-11T07:10:57.134829Z",
"shell.execute_reply": "2024-12-11T07:10:57.134208Z",
"shell.execute_reply.started": "2024-12-11T07:10:57.109746Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"78\n",
"78\n"
]
}
],
"source": [
"import json\n",
"import datetime\n",
"import csv\n",
"from datetime import date\n",
"\n",
"filename = '../item1.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",
"item['1']['en'] = 'lung'\n",
"item['2']['en'] = 'grip'\n",
"item['3']['en'] = 'flexion'\n",
"item['4']['en'] = 'jump'\n",
"item['5']['en'] = 'pushup'\n",
"item['6']['en'] = 'balance'\n",
"item['7']['en'] = 'reaction'\n",
"item['8']['en'] = 'step'\n",
"item['9']['en'] = 'situp'\n",
"item['10']['en'] = 'height'\n",
"item['11']['en'] = 'weight'\n",
"\n",
"\n",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/湖南石化青年体质检测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"\n",
"filename = 'data/places_result_20241205-1.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",
"#f_item = ['lung','grip','flexion','jump','balance','reaction','step','situp']\n",
"#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
"for result in list1:\n",
" user = str(result[2])\n",
" rq = date.fromisoformat(result[6].replace('/','-'))\n",
" if user in dict1.keys():\n",
" l_xm = []\n",
" m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex']\n",
" if dict1[user]['sex'] == '男':\n",
" l_xm = ['weight','height','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
" else:\n",
" l_xm = ['weight','height','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
" #birth = date.fromisoformat(dict1[user]['birth'])\n",
" #nian = int(birth[0].strip())\n",
" #yue = int(birth[1].strip())\n",
" #ri = int(birth[2].strip())\n",
" #print(k,nian,yue,ri)\n",
" item_name = item[m_item]['en'] \n",
" if item_name in l_xm: \n",
" days = (rq-birth).days \n",
" re_ta[user]['age'] = int(days/365)\n",
" re_ta[user]['month'] = int(days/365*12)\n",
" re_ta[user]['rq'] = result[6]\n",
"\n",
"\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n",
"filename = 'data/result_长炼医院人员2024(湖南青年).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
@@ -2487,20 +2664,20 @@
"id": "8af6a13c-3be4-44ff-a937-ee5061454484",
"metadata": {},
"source": [
"## 导出测试人员信息"
"## 导出测试人员信息(湖南青年)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 25,
"id": "64c6e1e3-801c-4573-b78f-5a9e842597a9",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-06T06:28:00.400775Z",
"iopub.status.busy": "2024-12-06T06:28:00.400061Z",
"iopub.status.idle": "2024-12-06T06:28:00.445938Z",
"shell.execute_reply": "2024-12-06T06:28:00.445528Z",
"shell.execute_reply.started": "2024-12-06T06:28:00.400712Z"
"iopub.execute_input": "2024-12-09T09:23:41.690512Z",
"iopub.status.busy": "2024-12-09T09:23:41.689765Z",
"iopub.status.idle": "2024-12-09T09:23:41.726298Z",
"shell.execute_reply": "2024-12-09T09:23:41.725869Z",
"shell.execute_reply.started": "2024-12-09T09:23:41.690440Z"
}
},
"outputs": [],
@@ -2515,7 +2692,7 @@
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/长炼医院人员2024(汇总).json'\n",
"filename = 'data/湖南石化青年体质检测.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
" \n",
@@ -2545,10 +2722,215 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "02501bf0-0ba8-4143-b2ef-aeef767985d0",
"metadata": {},
"source": [
"## 导出测试人员信息(非湖南青年)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "933f3eb1-8463-4782-ae45-8a1628abbb2b",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-09T09:29:03.983785Z",
"iopub.status.busy": "2024-12-09T09:29:03.983528Z",
"iopub.status.idle": "2024-12-09T09:29:04.043514Z",
"shell.execute_reply": "2024-12-09T09:29:04.042868Z",
"shell.execute_reply.started": "2024-12-09T09:29:03.983761Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n",
"filename = 'data/result_长炼医院人员2024.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",
" dict3 = json.load(fl)\n",
"\n",
"filename = 'data/长炼医院人员2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" if k in dict2.keys() and k not in dict3.keys():\n",
" list2 = []\n",
" list2.append(str(k).rjust(5,'0'))\n",
" list2.append(v['name']) \n",
" list2.append(dict2[k]['sex'])\n",
" list2.append(dict2[k]['unit'])\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/长炼医院人员检测情况表(非湖南青年).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": "83db1501-6625-4e72-9a5e-2184b8e309e9",
"metadata": {},
"source": [
"## 核对重名人员"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "dd7557bf-6f1e-4d01-aa93-5a4ad46a57a5",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T06:12:49.795632Z",
"iopub.status.busy": "2024-12-11T06:12:49.794818Z",
"iopub.status.idle": "2024-12-11T06:12:49.967842Z",
"shell.execute_reply": "2024-12-11T06:12:49.967393Z",
"shell.execute_reply.started": "2024-12-11T06:12:49.795561Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3437581 李成伟\n",
"3526193 李可\n",
"3464205 胡雨丹\n",
"1010 邱亮\n",
"1012 吴磊\n",
"3464081 刘权\n",
"3125625 宋霰\n",
"1020 贾俊\n",
"1022 徐敬\n",
"1023 彭一夫\n",
"1024 刘至清\n",
"1053 刘志刚\n",
"1058 杨红\n",
"1069 李鑫\n",
"1144 黄英杰\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n",
"filename = 'data/长炼医院人员2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"\n",
"filename = 'data/湖南石化青年体质检测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
" \n",
"set1 = set()\n",
"\n",
"for k, v in dict2.items():\n",
" set1.add(v['name'])\n",
"\n",
"for k, v in dict1.items():\n",
" if v['name'] in set1:\n",
" print(k,v['name'])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "ded0ac64-9ba2-4d64-9617-e0961b437d4e",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T06:33:09.011061Z",
"iopub.status.busy": "2024-12-11T06:33:09.010467Z",
"iopub.status.idle": "2024-12-11T06:33:09.030379Z",
"shell.execute_reply": "2024-12-11T06:33:09.029760Z",
"shell.execute_reply.started": "2024-12-11T06:33:09.011010Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"29\n",
"29\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = '../item1.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",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/长炼医院人员2024(汇总).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20241206.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[2])\n",
" if user in dict1.keys(): \n",
" m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n",
"filename = 'data/result_长炼医院人员2024(0417前).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f2345606-fe1b-49d4-b99b-f94aeec593eb",
"id": "7583ad54-3e66-4ef8-ae51-f01eda2bf647",
"metadata": {},
"outputs": [],
"source": []