20220927
This commit is contained in:
1 parent
b12a9e242d
commit
c037b1a44d
1 file changed
+322
-49
+322
-49
@@ -32,9 +32,8 @@
|
|||||||
"wb = openpyxl.load_workbook('data/安庆石化2022.xlsx')\n",
|
"wb = openpyxl.load_workbook('data/安庆石化2022.xlsx')\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"# sheets = wb.sheetnames\n",
|
"# sheets = wb.sheetnames\n",
|
||||||
"list1 = []\n",
|
|
||||||
"person = {}\n",
|
"person = {}\n",
|
||||||
"new_code = []\n",
|
"\n",
|
||||||
"for n in range(2, sheet.max_row+1):\n",
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
" code = int(sheet.cell(n, 2).value)\n",
|
" code = int(sheet.cell(n, 2).value)\n",
|
||||||
" person.setdefault(code, {})\n",
|
" person.setdefault(code, {})\n",
|
||||||
@@ -50,6 +49,197 @@
|
|||||||
"print('ok')"
|
"print('ok')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e5aa1bf4-c68c-4843-a9fb-c3fe48ff1f39",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 体测数据检查"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "27b8e925-ec99-48d4-9f89-97ce388c1b3b",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 数据项目校验"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "f93c3eed-ce79-48a7-b189-3ef694f60367",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import operator\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/安庆炼化人员名单2022.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"list1 = dict1.keys()\n",
|
||||||
|
"m_items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"f_items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_2209.json'\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" dict3[k] = v['sex']\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" list1 = []\n",
|
||||||
|
" list1 = list(v.keys()) \n",
|
||||||
|
" if dict3[k] == '男' and '一分钟仰卧起坐' in list1:\n",
|
||||||
|
" print(k,v['name'],'一分钟仰卧起坐 不应出现')\n",
|
||||||
|
" if dict3[k] == '女' and '俯卧撑' in list1:\n",
|
||||||
|
" print(k,v['name'],'俯卧撑 不应出现')\n",
|
||||||
|
" \n",
|
||||||
|
" "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "bd58fc48-ffe9-4838-be19-5da1dc632049",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 当日测试人员校验"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 226,
|
||||||
|
"id": "a00ec014-a4e5-4f8f-9cd5-7b3bd736ad85",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2022-09-27T14:02:23.012372Z",
|
||||||
|
"iopub.status.busy": "2022-09-27T14:02:23.011852Z",
|
||||||
|
"iopub.status.idle": "2022-09-27T14:02:23.095005Z",
|
||||||
|
"shell.execute_reply": "2022-09-27T14:02:23.093941Z",
|
||||||
|
"shell.execute_reply.started": "2022-09-27T14:02:23.012324Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"1892 马向东 该人员已经测试!\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import operator\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",
|
||||||
|
" \n",
|
||||||
|
"filename = 'data/136_220927.csv'\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"re_ta = {}\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",
|
||||||
|
"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",
|
||||||
|
"#print(re_ta)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_2209.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in re_ta.items():\n",
|
||||||
|
" if k in dict2.keys():\n",
|
||||||
|
" print(k,v['name'],'该人员已经测试!')\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "cf27c2e7-af3c-4765-af01-9326d7ebac6e",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 新增人员"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "80879f90-2939-44b8-8bc6-107c38c9df79",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/安庆新增人员220926.xlsx')\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"person = {}\n",
|
||||||
|
"dict2 = {}\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, 2).value)\n",
|
||||||
|
" person.setdefault(code, {})\n",
|
||||||
|
" dict1 = {}\n",
|
||||||
|
" xb = str(sheet.cell(n, 4).value)\n",
|
||||||
|
" if xb == '1':\n",
|
||||||
|
" sex = '男'\n",
|
||||||
|
" elif xb =='2':\n",
|
||||||
|
" sex = '女'\n",
|
||||||
|
" dict1['name'] = sheet.cell(n, 3).value\n",
|
||||||
|
" dict1['sex'] = sex\n",
|
||||||
|
" dict1['unit'] = sheet.cell(n, 1).value\n",
|
||||||
|
" dict1['id_num'] = sheet.cell(n,6).value\n",
|
||||||
|
" person[code] = dict1\n",
|
||||||
|
"filename = 'data/安庆炼化人员名单2022.json'\n",
|
||||||
|
"with open(filename, 'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"for k, v in person.items():\n",
|
||||||
|
" if k in dict2.keys():\n",
|
||||||
|
" print('该编号人员已存在!')\n",
|
||||||
|
" else:\n",
|
||||||
|
" dict2[k] = v\n",
|
||||||
|
" i +=1\n",
|
||||||
|
"if i >1:\n",
|
||||||
|
" with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||||||
|
" print('ok')\n",
|
||||||
|
"else:\n",
|
||||||
|
" print('无新增人员!')"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "5178b8fc-408a-4d95-915c-2164f2596bc3",
|
"id": "5178b8fc-408a-4d95-915c-2164f2596bc3",
|
||||||
@@ -102,26 +292,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 176,
|
"execution_count": null,
|
||||||
"id": "6e738a0d-ffbf-4a73-9021-d024609a6eb4",
|
"id": "6e738a0d-ffbf-4a73-9021-d024609a6eb4",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"tags": []
|
||||||
"iopub.execute_input": "2022-09-21T23:52:36.616675Z",
|
|
||||||
"iopub.status.busy": "2022-09-21T23:52:36.616155Z",
|
|
||||||
"iopub.status.idle": "2022-09-21T23:52:36.862741Z",
|
|
||||||
"shell.execute_reply": "2022-09-21T23:52:36.861607Z",
|
|
||||||
"shell.execute_reply.started": "2022-09-21T23:52:36.616627Z"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import time\n",
|
"import time\n",
|
||||||
@@ -141,7 +317,7 @@
|
|||||||
"dict1 = {}\n",
|
"dict1 = {}\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"#print(\"\\n运动项目信息:\")\n",
|
"#print(\"\\n运动项目信息:\")\n",
|
||||||
"filename = 'data/136_220921.csv'\n",
|
"filename = 'data/136_2209.csv'\n",
|
||||||
"with open(filename,'r',newline='') as csv_file:\n",
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
" header = next(fl) \n",
|
" header = next(fl) \n",
|
||||||
@@ -176,26 +352,46 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 177,
|
"execution_count": null,
|
||||||
|
"id": "bed95c43-e26c-41d3-8b1c-516818b25bbf",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_安庆.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/安庆炼化人员名单2022.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict3 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"for k, v in dict3.items():\n",
|
||||||
|
" dict2[v['id_num']] = [v['name'],k,v['unit'],v['sex']]\n",
|
||||||
|
"\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" if 'id' in v.keys():\n",
|
||||||
|
" if v['id'] in dict2.keys():\n",
|
||||||
|
" v['old_code'] = int(k)\n",
|
||||||
|
" code = int(dict2[v['id']][1])\n",
|
||||||
|
" dict3.setdefault(code, {})\n",
|
||||||
|
" dict3[code] = v \n",
|
||||||
|
"filename = 'data/安庆2021.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(dict3, fl,ensure_ascii=False) \n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
"id": "46ccfb31-7cd8-4cc4-8d70-18a14f7943e8",
|
"id": "46ccfb31-7cd8-4cc4-8d70-18a14f7943e8",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2022-09-21T23:59:09.201740Z",
|
|
||||||
"iopub.status.busy": "2022-09-21T23:59:09.201191Z",
|
|
||||||
"iopub.status.idle": "2022-09-21T23:59:10.457924Z",
|
|
||||||
"shell.execute_reply": "2022-09-21T23:59:10.456853Z",
|
|
||||||
"shell.execute_reply.started": "2022-09-21T23:59:09.201691Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
@@ -235,19 +431,19 @@
|
|||||||
"### 比照人员两年成绩"
|
"### 比照人员两年成绩"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "2b63fff4-3b1f-4a4f-b32a-4508736b88a6",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 比照两年全部成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 178,
|
"execution_count": null,
|
||||||
"id": "351aae7c-a3aa-4c22-99b9-701cf2395a85",
|
"id": "351aae7c-a3aa-4c22-99b9-701cf2395a85",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2022-09-22T00:00:18.837708Z",
|
|
||||||
"iopub.status.busy": "2022-09-22T00:00:18.837131Z",
|
|
||||||
"iopub.status.idle": "2022-09-22T00:00:20.116787Z",
|
|
||||||
"shell.execute_reply": "2022-09-22T00:00:20.115669Z",
|
|
||||||
"shell.execute_reply.started": "2022-09-22T00:00:18.837659Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -293,6 +489,67 @@
|
|||||||
"wb.save(filename) "
|
"wb.save(filename) "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "d6d6952f-2944-4cb4-8403-d83d5f0b4a9b",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 比照两年单项成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "28199ab8-ea9d-4012-ba75-9437fcdd91aa",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/安庆2021.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"list1 = dict1.keys()\n",
|
||||||
|
"items = ['身高','体重']\n",
|
||||||
|
"title = ['编号','姓名','部门','22年身高','22年体重','21年身高','21年体重','身高差','体重差']\n",
|
||||||
|
"filename = 'data/result_2209.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"list4 = []\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" if k in list1:\n",
|
||||||
|
" list2 = [k,v['name'],v['unit']]\n",
|
||||||
|
" list3 = []\n",
|
||||||
|
" for item in items:\n",
|
||||||
|
" # 获取2022年成绩\n",
|
||||||
|
" if item in v.keys(): \n",
|
||||||
|
" list2.append(v[item]['成绩'].split()[0]) \n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" # 获取2021年成绩\n",
|
||||||
|
" if item in dict1[k].keys():\n",
|
||||||
|
" list3.append(dict1[k][item]['成绩']) \n",
|
||||||
|
" else:\n",
|
||||||
|
" list3.append('')\n",
|
||||||
|
" for cj in list3:\n",
|
||||||
|
" if cj != '':\n",
|
||||||
|
" list2.append(cj.split()[0]) \n",
|
||||||
|
" \n",
|
||||||
|
" list4.append(list2)\n",
|
||||||
|
"filename = 'data/安庆石化成绩对照220927.xlsx'\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"sheet.append(title)\n",
|
||||||
|
"for row in list4:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename) "
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "f623d291-8d66-4246-a34f-a051115596ef",
|
"id": "f623d291-8d66-4246-a34f-a051115596ef",
|
||||||
@@ -671,6 +928,22 @@
|
|||||||
"id": "f2f2f206-2558-4cc3-9519-c4c677b71237",
|
"id": "f2f2f206-2558-4cc3-9519-c4c677b71237",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"filename = 'data/安庆2021.json'\n",
|
||||||
|
"item = {}\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"print(len(dict1))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "a7219084-9d0a-4027-9d51-5b6cc2f2ec9b",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in new issue
Block a user