20240713
This commit is contained in:
1 parent
daceb1e68d
commit
527c1710aa
5 files changed
+846
-792
No files matched your search
+289
-47
@@ -21,12 +21,11 @@
|
||||
"import json\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/天宫院体测人员名单.xlsx')\n",
|
||||
"wb = openpyxl.load_workbook('data/天宫院街道2024.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" if sheet.cell(n,1).value is not None:\n",
|
||||
" code = int(sheet.cell(n, 1).value)\n",
|
||||
@@ -34,16 +33,62 @@
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||||
" \n",
|
||||
" if sheet.cell(n,4).value is not None:\n",
|
||||
" dict1['sex'] = sheet.cell(n,4).value\n",
|
||||
" else:\n",
|
||||
" dict1['sex'] = ''\n",
|
||||
" dict1['birth'] = sheet.cell(n, 3).value\n",
|
||||
" \n",
|
||||
" dict1['sex'] = sheet.cell(n,3).value\n",
|
||||
" birth = str(sheet.cell(n, 4).value).split()[0]\n",
|
||||
" dict1['birth'] = birth.replace('/','-')\n",
|
||||
" \n",
|
||||
" person[code] = dict1\n",
|
||||
" if sheet.cell(n,5).value is not None:\n",
|
||||
" dict1['phone'] = sheet.cell(n,5).value\n",
|
||||
"\n",
|
||||
" person[code] = dict1\n",
|
||||
"filename = 'data/天宫院社区人员名单.json'\n",
|
||||
"filename = 'data/天宫院街道2024.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "b29a6f3c-035c-4c74-bbac-61e83be2b37c",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-07-11T08:18:28.633340Z",
|
||||
"iopub.status.busy": "2024-07-11T08:18:28.632568Z",
|
||||
"iopub.status.idle": "2024-07-11T08:18:28.654035Z",
|
||||
"shell.execute_reply": "2024-07-11T08:18:28.653382Z",
|
||||
"shell.execute_reply.started": "2024-07-11T08:18:28.633268Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/天宫院街道.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" if sheet.cell(n,1).value is not None:\n",
|
||||
" code = int(sheet.cell(n, 1).value)\n",
|
||||
" person.setdefault(code, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||||
" person[code] = dict1\n",
|
||||
"filename = 'data/天宫院街道all.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
@@ -122,14 +167,14 @@
|
||||
" dict1 = json.load(fl) \n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" item[k] = v\n",
|
||||
"filename = 'data/天宫院社区人员名单.json'\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",
|
||||
"re_ta = {}\n",
|
||||
"dict2 = {}\n",
|
||||
"list1 = []\n",
|
||||
"#print(\"\\n运动项目信息:\")\n",
|
||||
"filename = 'data/places_result_20230422.csv'\n",
|
||||
"\n",
|
||||
"filename = 'data/places_result_20240710.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -139,24 +184,89 @@
|
||||
"#print(list1)\n",
|
||||
"for result in list1:\n",
|
||||
" user = str(result[2])\n",
|
||||
" if user in dict1.keys():\n",
|
||||
" \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",
|
||||
" if 'sex' in dict1[user].keys():\n",
|
||||
" re_ta[user]['sex'] = dict1[user]['sex']\n",
|
||||
" else:\n",
|
||||
" re_ta[user]['sex'] = ' '\n",
|
||||
" re_ta[user]['sex'] = dict1[user]['sex'] \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",
|
||||
" re_ta[user][item_name]['得分'] =result[2]\n",
|
||||
"filename = 'data/result_天宫院.json'\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) \n",
|
||||
"print('ok')"
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "590775c3-16ef-43ad-99a2-85e847fe4079",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-07-11T08:19:29.653063Z",
|
||||
"iopub.status.busy": "2024-07-11T08:19:29.652598Z",
|
||||
"iopub.status.idle": "2024-07-11T08:19:29.662479Z",
|
||||
"shell.execute_reply": "2024-07-11T08:19:29.661939Z",
|
||||
"shell.execute_reply.started": "2024-07-11T08:19:29.653037Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"61\n",
|
||||
"61\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",
|
||||
"re_ta = {}\n",
|
||||
"dict1 = {}\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/天宫院街道all.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"filename = 'data/places_result_20240710.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",
|
||||
" 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_天宫院街道all.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -169,23 +279,49 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 10,
|
||||
"id": "c2ee2c71-7e28-4201-af85-ed7f001c6872",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-07-11T08:19:59.192307Z",
|
||||
"iopub.status.busy": "2024-07-11T08:19:59.191555Z",
|
||||
"iopub.status.idle": "2024-07-11T08:19:59.221577Z",
|
||||
"shell.execute_reply": "2024-07-11T08:19:59.220830Z",
|
||||
"shell.execute_reply.started": "2024-07-11T08:19:59.192234Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"101 李先生\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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[10], line 20\u001b[0m\n\u001b[1;32m 18\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;241m3\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m0\u001b[39m\u001b[38;5;124m'\u001b[39m))\n\u001b[1;32m 19\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(v[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m]) \n\u001b[0;32m---> 20\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(\u001b[43mdict2\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 23\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m item \u001b[38;5;129;01min\u001b[39;00m items:\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m item \u001b[38;5;129;01min\u001b[39;00m v\u001b[38;5;241m.\u001b[39mkeys():\n",
|
||||
"\u001b[0;31mKeyError\u001b[0m: 'sex'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"filename = 'data/result_天宫院.json'\n",
|
||||
"filename = 'data/result_天宫院街道.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/天宫院社区人员名单.json'\n",
|
||||
"filename = 'data/天宫院街道all.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
" \n",
|
||||
@@ -206,7 +342,128 @@
|
||||
" else:\n",
|
||||
" list2.append('') \n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/天宫院社区体测情况表.xlsx'\n",
|
||||
"filename = 'data/天宫院社区体测情况表_all.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": "code",
|
||||
"execution_count": 11,
|
||||
"id": "ddba1233-6ab2-480d-8bde-ed8e1c34e48e",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-07-11T08:20:48.587834Z",
|
||||
"iopub.status.busy": "2024-07-11T08:20:48.587065Z",
|
||||
"iopub.status.idle": "2024-07-11T08:20:48.615936Z",
|
||||
"shell.execute_reply": "2024-07-11T08:20:48.615410Z",
|
||||
"shell.execute_reply.started": "2024-07-11T08:20:48.587764Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"101 李有才\n",
|
||||
"44 星众豪\n",
|
||||
"94 谢红印\n",
|
||||
"14 孙一萂\n",
|
||||
"132 梁正文\n",
|
||||
"123 刘\n",
|
||||
"93 李洪芝\n",
|
||||
"71 李羽馨\n",
|
||||
"91 孙婧祎\n",
|
||||
"8 王红晶\n",
|
||||
"126 马\n",
|
||||
"125 陈\n",
|
||||
"6 刘艳\n",
|
||||
"96 薛颖\n",
|
||||
"2 刘书本\n",
|
||||
"40 杨春华\n",
|
||||
"9 霍思诺\n",
|
||||
"124 苗\n",
|
||||
"128 张\n",
|
||||
"78 朱蕊\n",
|
||||
"10 李晨曦\n",
|
||||
"5 李芳\n",
|
||||
"100 聂彦芹\n",
|
||||
"4 富红\n",
|
||||
"68 冯瑞文\n",
|
||||
"108 杨\n",
|
||||
"130 徐\n",
|
||||
"86 阎树芹\n",
|
||||
"83 张万成\n",
|
||||
"116 白景香\n",
|
||||
"103 王梓涵\n",
|
||||
"15 王慧兰\n",
|
||||
"36 冯玉红\n",
|
||||
"118 王玉芬\n",
|
||||
"102 王岩东\n",
|
||||
"19 张竹辰\n",
|
||||
"38 路德慧\n",
|
||||
"111 张\n",
|
||||
"37 张影\n",
|
||||
"25 孟现春\n",
|
||||
"41 朱朝云\n",
|
||||
"85 武宜国\n",
|
||||
"107 刘连英\n",
|
||||
"20 王韵琪\n",
|
||||
"7 李雪\n",
|
||||
"18 王真秀\n",
|
||||
"98 张建霞\n",
|
||||
"131 陈艳莉\n",
|
||||
"106 沈建新\n",
|
||||
"43 杨桂兰\n",
|
||||
"127 张\n",
|
||||
"39 韩润壮\n",
|
||||
"129 薛\n",
|
||||
"110 赵\n",
|
||||
"79 郭忠臣\n",
|
||||
"81 赵淑芬\n",
|
||||
"115 朱\n",
|
||||
"114 王淑云\n",
|
||||
"62 赵秀香\n",
|
||||
"31 张成林\n",
|
||||
"99 张东喜\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"filename = 'data/result_天宫院街道all.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/天宫院街道all.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",
|
||||
" print(k,v['name'])\n",
|
||||
" list2.append(str(k).rjust(3,'0'))\n",
|
||||
" list2.append(v['name']) \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/天宫院社区体测情况表_all.xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
@@ -267,27 +524,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 41,
|
||||
"execution_count": null,
|
||||
"id": "08ce9a37-b40c-4cb7-8c12-f18e2ecfc462",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-23T08:52:01.769840Z",
|
||||
"iopub.status.busy": "2023-04-23T08:52:01.768890Z",
|
||||
"iopub.status.idle": "2023-04-23T08:52:01.785005Z",
|
||||
"shell.execute_reply": "2023-04-23T08:52:01.783964Z",
|
||||
"shell.execute_reply.started": "2023-04-23T08:52:01.769799Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os,sys,shutil\n",
|
||||
"import json\n",
|
||||
@@ -343,7 +585,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.6"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in new issue
Block a user