diff --git a/体测单位/巴陵石化.ipynb b/体测单位/巴陵石化.ipynb deleted file mode 100644 index ab9992e..0000000 --- a/体测单位/巴陵石化.ipynb +++ /dev/null @@ -1,322 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "37eee6b1-ddbc-414c-ac74-e831c53c9bdb", - "metadata": {}, - "source": [ - "### 人员基本信息导入" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "a27e986c-0c40-4792-b24d-03b19df707a9", - "metadata": { - "execution": { - "iopub.execute_input": "2022-11-03T12:05:14.162807Z", - "iopub.status.busy": "2022-11-03T12:05:14.162264Z", - "iopub.status.idle": "2022-11-03T12:05:15.514597Z", - "shell.execute_reply": "2022-11-03T12:05:15.513708Z", - "shell.execute_reply.started": "2022-11-03T12:05:14.162759Z" - }, - "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": 4, - "id": "e5e4145b-d575-46b5-a530-c722668f76f3", - "metadata": { - "execution": { - "iopub.execute_input": "2022-11-03T12:04:52.389836Z", - "iopub.status.busy": "2022-11-03T12:04:52.389246Z", - "iopub.status.idle": "2022-11-03T12:04:52.901781Z", - "shell.execute_reply": "2022-11-03T12:04:52.900587Z", - "shell.execute_reply.started": "2022-11-03T12:04:52.389788Z" - }, - "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": 7, - "id": "0582bc84-7234-415f-9715-66c27b6b8f91", - "metadata": { - "execution": { - "iopub.execute_input": "2022-11-03T12:05:19.504467Z", - "iopub.status.busy": "2022-11-03T12:05:19.503886Z", - "iopub.status.idle": "2022-11-03T12:05:21.059764Z", - "shell.execute_reply": "2022-11-03T12:05:21.058715Z", - "shell.execute_reply.started": "2022-11-03T12:05:19.504418Z" - }, - "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(5,'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/巴陵石化体测情况表(截至20221103).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 -}