diff --git a/体测单位/天津石化.ipynb b/体测单位/天津石化.ipynb index bfb4a39..3909a72 100644 --- a/体测单位/天津石化.ipynb +++ b/体测单位/天津石化.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 12, "id": "1144aaac-92a0-4bcf-aba7-096f7dd3ad3b", "metadata": { "execution": { - "iopub.execute_input": "2022-10-15T14:33:57.992886Z", - "iopub.status.busy": "2022-10-15T14:33:57.992353Z", - "iopub.status.idle": "2022-10-15T14:33:59.266279Z", - "shell.execute_reply": "2022-10-15T14:33:59.265333Z", - "shell.execute_reply.started": "2022-10-15T14:33:57.992838Z" + "iopub.execute_input": "2022-10-24T01:23:19.812476Z", + "iopub.status.busy": "2022-10-24T01:23:19.811935Z", + "iopub.status.idle": "2022-10-24T01:23:21.182395Z", + "shell.execute_reply": "2022-10-24T01:23:21.180972Z", + "shell.execute_reply.started": "2022-10-24T01:23:19.812426Z" }, "tags": [] }, @@ -42,7 +42,7 @@ "person = {}\n", "\n", "for n in range(2, sheet.max_row+1):\n", - " code = sheet.cell(n, 6).value\n", + " code = int(sheet.cell(n, 6).value)\n", " person.setdefault(code, {})\n", " dict1 = {}\n", " dict1['name'] = sheet.cell(n, 3).value\n", @@ -57,10 +57,151 @@ "print('ok')" ] }, + { + "cell_type": "markdown", + "id": "5e648b69-40bf-4494-9079-e4e2b6ab8866", + "metadata": {}, + "source": [ + "## 获取人员测试成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a57ebb22-543c-4804-8d44-89984058ec1d", + "metadata": { + "execution": { + "iopub.execute_input": "2022-10-24T01:21:48.803009Z", + "iopub.status.busy": "2022-10-24T01:21:48.802465Z", + "iopub.status.idle": "2022-10-24T01:21:48.864714Z", + "shell.execute_reply": "2022-10-24T01:21:48.863863Z", + "shell.execute_reply.started": "2022-10-24T01:21:48.802959Z" + }, + "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/134_221021.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": "55d961e5-a512-44b2-808e-7c55d7000d52", + "metadata": {}, + "source": [ + "## 导出测试成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "38397ad4-2bb3-4b5e-8ece-9ea11e801890", + "metadata": { + "execution": { + "iopub.execute_input": "2022-10-24T01:28:35.781995Z", + "iopub.status.busy": "2022-10-24T01:28:35.781432Z", + "iopub.status.idle": "2022-10-24T01:28:36.097993Z", + "shell.execute_reply": "2022-10-24T01:28:36.097009Z", + "shell.execute_reply.started": "2022-10-24T01:28:35.781947Z" + }, + "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", + " list2.append(dict2[k]['sub_unit'])\n", + " \n", + " for item in items:\n", + " if item in v.keys():\n", + " list2.append(v[item]['成绩'])\n", + " list2.append(v[item]['得分'])\n", + " elif item =='name':\n", + " list2.append(v[item])\n", + " else:\n", + " list2.append('') \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": "code", "execution_count": null, - "id": "bf980970-b95f-47f3-a93d-55a659f52471", + "id": "92ff6604-e754-4d74-9114-9df466a64e9f", "metadata": {}, "outputs": [], "source": []