This commit is contained in:
512song committed 2024-07-05 00:28:44 +08:00
1 parent 1523d4503b
commit 9d428b40d4
5 files changed
+650 -162

No files matched your search

+208 -3
View File
@@ -4,6 +4,7 @@
"cell_type": "markdown",
"id": "55644860-57e6-466b-b6e9-e6fdd807498d",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
@@ -53,7 +54,7 @@
" dict1['birth'] = birth\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" person[code] = dict1\n",
"filename = 'data/长炼医院人员名单.json'\n",
"filename = 'data/长炼医院人员2024.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
@@ -1985,7 +1986,9 @@
{
"cell_type": "markdown",
"id": "78942564-c286-4f4e-8d89-515a2b4b4c86",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"# 员工数据分析"
]
@@ -2482,10 +2485,212 @@
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人,男性:{m}人')"
]
},
{
"cell_type": "markdown",
"id": "6b0651da-ade9-4cb4-b1c1-12b9e4dc267a",
"metadata": {},
"source": [
"# 员工体测2024年"
]
},
{
"cell_type": "code",
"execution_count": 1,
"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"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/长炼医院测花名册(2024年).xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, 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/长炼医院人员2024.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "b056832e-049c-40f4-b7e7-adac6976bf77",
"metadata": {},
"source": [
"## 获取人员测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"65\n",
"65\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",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/长炼医院人员2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20240704.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[2])\n",
" if user in dict1.keys(): \n",
" m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" 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",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
]
},
{
"cell_type": "markdown",
"id": "8af6a13c-3be4-44ff-a937-ee5061454484",
"metadata": {},
"source": [
"## 导出测试人员信息"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n",
"filename = 'data/result_长炼医院(2024年).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/长炼医院人员2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
" \n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" if k in dict2.keys():\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",
" 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/长炼医院人员202406.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": "dcf80c81-907f-4397-8ebf-7b9234e63af1",
"id": "f2345606-fe1b-49d4-b99b-f94aeec593eb",
"metadata": {},
"outputs": [],
"source": []