diff --git a/体测单位/北海炼化.ipynb b/体测单位/北海炼化.ipynb index 17d3f2e..a667168 100644 --- a/体测单位/北海炼化.ipynb +++ b/体测单位/北海炼化.ipynb @@ -650,7 +650,6 @@ "cell_type": "markdown", "id": "1ab2aa22-5cc2-4f53-a28d-b30b1ecab15f", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -1109,15 +1108,15 @@ }, { "cell_type": "code", - "execution_count": 104, + "execution_count": 106, "id": "0bafbf66-c909-413e-a9c1-c1a5f9c22953", "metadata": { "execution": { - "iopub.execute_input": "2023-11-08T01:55:15.141433Z", - "iopub.status.busy": "2023-11-08T01:55:15.141150Z", - "iopub.status.idle": "2023-11-08T01:55:15.238893Z", - "shell.execute_reply": "2023-11-08T01:55:15.238339Z", - "shell.execute_reply.started": "2023-11-08T01:55:15.141408Z" + "iopub.execute_input": "2023-11-14T05:55:33.805333Z", + "iopub.status.busy": "2023-11-14T05:55:33.804539Z", + "iopub.status.idle": "2023-11-14T05:55:33.957265Z", + "shell.execute_reply": "2023-11-14T05:55:33.956626Z", + "shell.execute_reply.started": "2023-11-14T05:55:33.805258Z" }, "tags": [] }, @@ -1220,15 +1219,15 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 107, "id": "1aa45b35-7376-4c50-8275-79b090a6c758", "metadata": { "execution": { - "iopub.execute_input": "2023-11-11T02:58:46.399097Z", - "iopub.status.busy": "2023-11-11T02:58:46.398632Z", - "iopub.status.idle": "2023-11-11T02:58:46.503284Z", - "shell.execute_reply": "2023-11-11T02:58:46.502753Z", - "shell.execute_reply.started": "2023-11-11T02:58:46.399061Z" + "iopub.execute_input": "2023-11-14T06:00:16.626017Z", + "iopub.status.busy": "2023-11-14T06:00:16.625735Z", + "iopub.status.idle": "2023-11-14T06:00:16.685336Z", + "shell.execute_reply": "2023-11-14T06:00:16.684762Z", + "shell.execute_reply.started": "2023-11-14T06:00:16.625993Z" }, "tags": [] }, @@ -1237,8 +1236,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "607\n", - "607\n" + "697\n", + "697\n" ] } ], @@ -1261,7 +1260,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", - "filename = 'data/places_result_20231111.csv'\n", + "filename = 'data/places_result_20231114.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -1344,10 +1343,104 @@ "wb.save(filename)" ] }, + { + "cell_type": "markdown", + "id": "c410f403-5c93-4a03-a06b-900ecd08a1b4", + "metadata": {}, + "source": [ + "## 导入问卷信息" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "id": "63d5bccf-7351-4a08-863d-b1ca3b263eca", + "metadata": { + "execution": { + "iopub.execute_input": "2023-11-14T06:14:23.732763Z", + "iopub.status.busy": "2023-11-14T06:14:23.732454Z", + "iopub.status.idle": "2023-11-14T06:14:23.789472Z", + "shell.execute_reply": "2023-11-14T06:14:23.788550Z", + "shell.execute_reply.started": "2023-11-14T06:14:23.732734Z" + }, + "tags": [] + }, + "outputs": [ + { + "ename": "ValueError", + "evalue": "invalid literal for int() with base 10: 'ender'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[113], line 38\u001b[0m\n\u001b[1;32m 36\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;241m0\u001b[39m)\n\u001b[1;32m 37\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m content\u001b[38;5;241m.\u001b[39mitems():\n\u001b[0;32m---> 38\u001b[0m i \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mk\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 39\u001b[0m list2[i\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m] \u001b[38;5;241m=\u001b[39m v\n\u001b[1;32m 40\u001b[0m dict2[item[\u001b[38;5;241m2\u001b[39m]] \u001b[38;5;241m=\u001b[39m list2\n", + "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: 'ender'" + ] + } + ], + "source": [ + "import json\n", + "import csv\n", + "import openpyxl\n", + "import time\n", + "from datetime import date\n", + "\n", + "filename = 'data/result_北海炼化2023.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "filename = 'data/北海炼化2023年.json'\n", + "with open(filename,'r') as fl:\n", + " dict3 = json.load(fl)\n", + "\n", + "phone = set()\n", + "phone1 = set()\n", + "for k,v in dict3.items():\n", + " if 'phone' in v.keys():\n", + " phone.add(v['phone'])\n", + "list1 = []\n", + "filename = 'data/Survey_20231114.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", + "dict2 = {}\n", + "m_rq = '2023-11-14'\n", + "rq= date.fromisoformat(m_rq.replace('/','-'))\n", + "for item in list1:\n", + " if item[2] in phone: \n", + " content = json.loads(item[5])\n", + " list2 = []\n", + " for i in range(0,60):\n", + " list2.append(0)\n", + " for k, v in content.items():\n", + " i = int(k[1:])\n", + " list2[i-1] = v\n", + " dict2[item[2]] = list2\n", + "print(dict2) \n", + "for k, v in dict3.items():\n", + " if 'phone' in v.keys() and v['phone'] in dict2.keys():\n", + " if k not in dict1.keys():\n", + " dict1.setdefault(k,{})\n", + " dict1[k] = dict3[k]\n", + " days = (rq-birth).days \n", + " dict1[k]['age'] = int(days/365)\n", + " dict1[k]['month'] = int(days/365*12)\n", + " \n", + " dict1[k]['tcm'] = dict2[str(v['phone'])]\n", + " \n", + "filename = 'data/result_北海炼化new.json'\n", + "\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl, ensure_ascii=False) " + ] + }, { "cell_type": "code", "execution_count": null, - "id": "7111dc19-387c-4e4d-bfed-0273cf0809fb", + "id": "c0128f52-8697-4258-aba0-89a522fb9cc0", "metadata": {}, "outputs": [], "source": [] diff --git a/体测单位/天津石化.ipynb b/体测单位/天津石化.ipynb index 818c6ff..0e9209b 100644 --- a/体测单位/天津石化.ipynb +++ b/体测单位/天津石化.ipynb @@ -2308,7 +2308,7 @@ "for fn in fls:\n", " fi_name =Path(fn).stem.split('-')[0]\n", " code = int(fi_name)\n", - " if dict1[str(code)]['sex'] =='女': \n", + " if dict1[str(code)]['sex'] =='男': \n", " unit_path = Path(new_path,dict1[str(code)]['unit'])\n", " unit_path.mkdir(parents = True, exist_ok = True)\n", " n_name = Path(unit_path,Path(fn).stem+'.pdf')\n", @@ -2369,12 +2369,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 92, "id": "91fbc553-da7c-4c1e-bcf3-944dc59204b6", "metadata": { + "execution": { + "iopub.execute_input": "2023-11-14T06:24:29.017502Z", + "iopub.status.busy": "2023-11-14T06:24:29.016683Z", + "iopub.status.idle": "2023-11-14T06:24:29.082247Z", + "shell.execute_reply": "2023-11-14T06:24:29.081478Z", + "shell.execute_reply.started": "2023-11-14T06:24:29.017425Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[]\n", + "ok\n" + ] + } + ], "source": [ "import os,sys,shutil\n", "import json\n", @@ -2393,13 +2409,13 @@ " list2 = []\n", " fi_name =Path(fn).stem.split('-')[0] \n", " code = int(fi_name)\n", - " if dict1[str(code)]['sex'] =='女':\n", + " if dict1[str(code)]['sex'] =='男':\n", " unit = dict1[str(code)]['unit']\n", " list2 = [fi_name,Path(fn).stem.split('-')[1],unit]\n", " \n", " list1.append(list2)\n", "print(list1)\n", - "filename = 'data/天津石化体测报告打印明细表(修改).xlsx'\n", + "filename = 'data/天津石化体测报告打印明细表(第一批).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -2631,18 +2647,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 87, "id": "006afc6c-2b1f-4edf-be1b-5f60e2029ee8", "metadata": { + "execution": { + "iopub.execute_input": "2023-11-14T05:31:33.869705Z", + "iopub.status.busy": "2023-11-14T05:31:33.869187Z", + "iopub.status.idle": "2023-11-14T05:31:33.963951Z", + "shell.execute_reply": "2023-11-14T05:31:33.963038Z", + "shell.execute_reply.started": "2023-11-14T05:31:33.869655Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0~255分人数:1641人,男性:1334人,女性:307人\n", + "256~332分人数:1544人,男性:941人,女性:603人\n", + "333~367分人数:354人,男性:191人,女性:163人\n", + "368~500分人数:118人,男性:39人,女性:79人\n", + "3657\n" + ] + } + ], "source": [ "import json\n", "\n", "items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "\n", - "filename = 'data/data_天津231017.json'\n", + "filename = 'data/data_天津231017_非倒班.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "dict2 = {}\n", @@ -2679,12 +2714,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 88, "id": "949e4c3c-023d-44a4-b99e-c5460da61161", "metadata": { + "execution": { + "iopub.execute_input": "2023-11-14T05:32:00.827469Z", + "iopub.status.busy": "2023-11-14T05:32:00.826734Z", + "iopub.status.idle": "2023-11-14T05:32:00.923421Z", + "shell.execute_reply": "2023-11-14T05:32:00.922591Z", + "shell.execute_reply.started": "2023-11-14T05:32:00.827429Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20~24岁平均成绩:2.45分,人数:581人,男性:384人\n", + "25~29岁平均成绩:2.56分,人数:369人,男性:252人\n", + "30~34岁平均成绩:2.56分,人数:211人,男性:144人\n", + "35~39岁平均成绩:2.67分,人数:414人,男性:281人\n", + "40~44岁平均成绩:2.7分,人数:318人,男性:188人\n", + "45~49岁平均成绩:2.71分,人数:563人,男性:310人\n", + "50~54岁平均成绩:2.63分,人数:849人,男性:594人\n", + "55~69岁平均成绩:2.46分,人数:352人,男性:352人\n" + ] + } + ], "source": [ "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]\n", "\n", @@ -2717,12 +2774,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 86, "id": "721977d3-5816-4bf6-82fc-26fd170e5454", "metadata": { + "execution": { + "iopub.execute_input": "2023-11-14T05:29:45.231085Z", + "iopub.status.busy": "2023-11-14T05:29:45.230706Z", + "iopub.status.idle": "2023-11-14T05:29:45.291777Z", + "shell.execute_reply": "2023-11-14T05:29:45.290397Z", + "shell.execute_reply.started": "2023-11-14T05:29:45.231052Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20~24岁平均成绩:2.42分,人数:322人\n", + "25~29岁平均成绩:2.54分,人数:120人\n", + "30~34岁平均成绩:2.61分,人数:21人\n", + "35~39岁平均成绩:2.23分,人数:47人\n", + "40~44岁平均成绩:2.46分,人数:57人\n", + "45~49岁平均成绩:2.4分,人数:156人\n", + "50~54岁平均成绩:2.39分,人数:335人\n", + "55~80岁平均成绩:2.5分,人数:225人\n" + ] + } + ], "source": [ "import json\n", "\n", @@ -2795,12 +2874,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 90, "id": "7155f2c2-0719-4558-aa3b-629fb70194d6", "metadata": { + "execution": { + "iopub.execute_input": "2023-11-14T05:32:38.731026Z", + "iopub.status.busy": "2023-11-14T05:32:38.730664Z", + "iopub.status.idle": "2023-11-14T05:32:38.802327Z", + "shell.execute_reply": "2023-11-14T05:32:38.801563Z", + "shell.execute_reply.started": "2023-11-14T05:32:38.730994Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "平均成绩:2.4823分,男性:2505人\n", + "平均成绩:2.8604分,女性:1152人\n", + "平均成绩:2.6014分,总体:3657人\n" + ] + } + ], "source": [ "import json\n", "\n", @@ -2826,7 +2922,7 @@ " score = score+v['score']\n", "print(f'平均成绩:{round(score/f,4)}分,女性:{f}人')\n", "t_score = t_score + score\n", - "print(f'平均成绩:{round(t_score/5383,4)}分,总体:5383人')" + "print(f'平均成绩:{round(t_score/3657,4)}分,总体:3657人')" ] }, { @@ -2925,6 +3021,60 @@ "print('ok')" ] }, + { + "cell_type": "markdown", + "id": "194217e0-f1cf-4945-ad5a-52304ed2f943", + "metadata": {}, + "source": [ + "## 计算各项目成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "id": "5ed284c6-1a1c-43ab-92a8-b3c411cd77a1", + "metadata": { + "execution": { + "iopub.execute_input": "2023-11-14T05:34:30.789468Z", + "iopub.status.busy": "2023-11-14T05:34:30.789112Z", + "iopub.status.idle": "2023-11-14T05:34:30.903912Z", + "shell.execute_reply": "2023-11-14T05:34:30.903118Z", + "shell.execute_reply.started": "2023-11-14T05:34:30.789436Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "BMI 3.54 3634\n", + "肺活量 3.37 3569\n", + "握力 1.29 3592\n", + "坐位体前屈 2.85 3142\n", + "纵跳 2.0 3198\n", + "俯卧撑 2.57 2082\n", + "一分钟仰卧起坐 3.94 757\n", + "单脚站立 2.01 3523\n", + "选择反应时 2.97 3613\n", + "台阶指数 2.58 1496\n" + ] + } + ], + "source": [ + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "for item in items:\n", + " score = 0\n", + " n = 0\n", + " for k, v in dict1.items(): \n", + " if item in v['fits'].keys():\n", + " n = n + 1\n", + " score =score + int(v['fits'][item]['score'])\n", + " print(item,round(score/n,2),n)" + ] + }, { "cell_type": "markdown", "id": "5a130857-4dd1-4b5e-b21b-42fe32b367cf", @@ -3101,15 +3251,15 @@ }, { "cell_type": "code", - "execution_count": 253, + "execution_count": 80, "id": "518a1e40-d383-4d78-a4ea-224ddab49b79", "metadata": { "execution": { - "iopub.execute_input": "2023-11-10T13:59:53.477003Z", - "iopub.status.busy": "2023-11-10T13:59:53.476599Z", - "iopub.status.idle": "2023-11-10T13:59:54.275449Z", - "shell.execute_reply": "2023-11-10T13:59:54.274890Z", - "shell.execute_reply.started": "2023-11-10T13:59:53.476972Z" + "iopub.execute_input": "2023-11-14T04:54:34.744376Z", + "iopub.status.busy": "2023-11-14T04:54:34.744069Z", + "iopub.status.idle": "2023-11-14T04:54:36.013106Z", + "shell.execute_reply": "2023-11-14T04:54:36.012373Z", + "shell.execute_reply.started": "2023-11-14T04:54:34.744349Z" }, "tags": [] }, @@ -3118,7 +3268,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "1726\n" + "3657\n" ] } ], @@ -3137,19 +3287,73 @@ "# sheets = wb.sheetnames\n", "dict2 = {}\n", "i = 1\n", - "for n in range(2, sheet.max_row+1):\n", + "for n in range(4, sheet.max_row+1):\n", " if sheet.cell(n, 1).value is not None:\n", " code = int(sheet.cell(n, 1).value)\n", " daoban = sheet.cell(n, 6).value\n", " if str(code) in dict1.keys() and daoban == '倒班':\n", " dict2[str(code)] = dict1[str(code)]\n", - "print(len(dict2))" + "filename = 'data/data_天津231017_倒班.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict2, fl) \n", + "dict3 = {}\n", + "for k, v in dict1.items():\n", + " if k not in dict2.keys():\n", + " dict3[k] = dict1[k]\n", + "print(len(dict3))\n", + " \n", + "filename = 'data/data_天津231017_非倒班.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict3, fl) \n" + ] + }, + { + "cell_type": "markdown", + "id": "cf45ba36-896d-4d28-ae4a-08c512ff1ddb", + "metadata": {}, + "source": [ + "### 核对倒班员工信息" ] }, { "cell_type": "code", "execution_count": null, "id": "08167b05-8719-41c9-a71d-57906a55eb63", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "\n", + "filename = 'data/data_天津231017.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "\n", + " \n", + "wb = openpyxl.load_workbook('data/员工个人基础信息-倒班.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "dict2 = {}\n", + "i = 0\n", + "for n in range(4, sheet.max_row+1):\n", + " if sheet.cell(n, 1).value is not None:\n", + " code = int(sheet.cell(n, 1).value)\n", + " daoban = sheet.cell(n, 6).value\n", + " if str(code) in dict1.keys():# and daoban != '倒班':\n", + " dict2[str(code)] = dict1[str(code)]\n", + "for k,v in dict1.items():\n", + " if str(k) not in dict2.keys():\n", + " i+=1\n", + " print(i,k,v['name'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "54b2abad-9891-4e06-93b7-ca5c0659ea49", "metadata": {}, "outputs": [], "source": []