This commit is contained in:
512song committed 2024-07-07 13:14:06 +08:00
1 parent 9d428b40d4
commit d1ae0ac764
5 files changed
+594 -248

No files matched your search

+91 -38
View File
@@ -2495,15 +2495,72 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"id": "0b877c2a-7fb3-4b34-81ab-58b9a09c4890",
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-04T12:14:19.043925Z",
"iopub.status.busy": "2024-07-04T12:14:19.042643Z",
"iopub.status.idle": "2024-07-04T12:14:19.424433Z",
"shell.execute_reply": "2024-07-04T12:14:19.423870Z",
"shell.execute_reply.started": "2024-07-04T12:14:19.043842Z"
"iopub.execute_input": "2024-07-05T08:13:23.061813Z",
"iopub.status.busy": "2024-07-05T08:13:23.061107Z",
"iopub.status.idle": "2024-07-05T08:13:23.223541Z",
"shell.execute_reply": "2024-07-05T08:13:23.222824Z",
"shell.execute_reply.started": "2024-07-05T08:13:23.061752Z"
}
},
"outputs": [
{
"ename": "ValueError",
"evalue": "invalid literal for int() with base 10: '姓\\xa0 名'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 12\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m n \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m2\u001b[39m, sheet\u001b[38;5;241m.\u001b[39mmax_row\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m1\u001b[39m):\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m sheet\u001b[38;5;241m.\u001b[39mcell(n,\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mvalue \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m---> 12\u001b[0m code \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43msheet\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcell\u001b[49m\u001b[43m(\u001b[49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m4\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalue\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 13\u001b[0m person\u001b[38;5;241m.\u001b[39msetdefault(code, {})\n\u001b[1;32m 14\u001b[0m dict1 \u001b[38;5;241m=\u001b[39m {}\n",
"\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: '姓\\xa0 名'"
]
}
],
"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(3, sheet.max_row+1):\n",
" if sheet.cell(n,1).value is not None:\n",
" code = int(sheet.cell(n, 4).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 6).value\n",
" if int(sheet.cell(n, 7).value) ==1:\n",
" sex = '男'\n",
" else:\n",
" sex = '女'\n",
" dict1['sex'] = sex\n",
" birth = str(sheet.cell(n, 8).value).split()[0]\n",
" dict1['birth'] = birth\n",
" dict1['unit'] = sheet.cell(n, 3).value\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": "code",
"execution_count": 5,
"id": "610b20f3-9fd8-46fc-b8ee-d48c4c854289",
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-05T08:16:56.784551Z",
"iopub.status.busy": "2024-07-05T08:16:56.783955Z",
"iopub.status.idle": "2024-07-05T08:16:56.816327Z",
"shell.execute_reply": "2024-07-05T08:16:56.815741Z",
"shell.execute_reply.started": "2024-07-05T08:16:56.784528Z"
}
},
"outputs": [
@@ -2520,27 +2577,23 @@
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/长炼医院测花名册(2024年).xlsx')\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",
"for n in range(3, sheet.max_row+1):\n",
" if sheet.cell(n,1).value is not None:\n",
" code = int(sheet.cell(n, 4).value)\n",
" code = int(sheet.cell(n, 3).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 6).value\n",
" if int(sheet.cell(n, 7).value) ==1:\n",
" sex = '男'\n",
" else:\n",
" sex = '女'\n",
" dict1['sex'] = sex\n",
" dict1['name'] = sheet.cell(n, 4).value\n",
" dict1['sex'] = sheet.cell(n, 5).value\n",
" birth = str(sheet.cell(n, 8).value).split()[0]\n",
" dict1['birth'] = birth\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" person[code] = dict1\n",
"filename = 'data/长炼医院人员2024.json'\n",
"filename = 'data/湖南石化青年体质检测.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
@@ -2556,15 +2609,15 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"id": "1e2d586e-6ff5-4fd1-a909-278d23e54561",
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-04T12:19:29.383802Z",
"iopub.status.busy": "2024-07-04T12:19:29.383485Z",
"iopub.status.idle": "2024-07-04T12:19:29.401169Z",
"shell.execute_reply": "2024-07-04T12:19:29.400657Z",
"shell.execute_reply.started": "2024-07-04T12:19:29.383777Z"
"iopub.execute_input": "2024-07-05T08:17:44.237801Z",
"iopub.status.busy": "2024-07-05T08:17:44.236968Z",
"iopub.status.idle": "2024-07-05T08:17:44.258525Z",
"shell.execute_reply": "2024-07-05T08:17:44.258007Z",
"shell.execute_reply.started": "2024-07-05T08:17:44.237723Z"
}
},
"outputs": [
@@ -2572,8 +2625,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"65\n",
"65\n"
"80\n",
"80\n"
]
}
],
@@ -2592,11 +2645,11 @@
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/长炼医院人员2024.json'\n",
"filename = 'data/湖南石化青年体质检测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20240704.csv'\n",
"filename = 'data/places_result_20240705.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -2617,7 +2670,7 @@
" 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_湖南石化青年体质检测.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
@@ -2634,15 +2687,15 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "64c6e1e3-801c-4573-b78f-5a9e842597a9",
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-04T12:21:46.281916Z",
"iopub.status.busy": "2024-07-04T12:21:46.281196Z",
"iopub.status.idle": "2024-07-04T12:21:46.315546Z",
"shell.execute_reply": "2024-07-04T12:21:46.315046Z",
"shell.execute_reply.started": "2024-07-04T12:21:46.281853Z"
"iopub.execute_input": "2024-07-05T08:18:34.776458Z",
"iopub.status.busy": "2024-07-05T08:18:34.775705Z",
"iopub.status.idle": "2024-07-05T08:18:34.806013Z",
"shell.execute_reply": "2024-07-05T08:18:34.805581Z",
"shell.execute_reply.started": "2024-07-05T08:18:34.776387Z"
}
},
"outputs": [],
@@ -2651,13 +2704,13 @@
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n",
"filename = 'data/result_长炼医院(2024年).json'\n",
"filename = 'data/result_湖南石化青年体质检测.json'\n",
"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",
@@ -2677,7 +2730,7 @@
" else:\n",
" list2.append('') \n",
" list1.append(list2)\n",
"filename = 'data/长炼医院人员202406.xlsx'\n",
"filename = 'data/湖南石化青年体质检测.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",