This commit is contained in:
512song@sina.com committed 2023-03-24 19:39:11 +08:00
1 parent d30e4b0ca7
commit 177370c8e1
2 files changed
+269 -9

No files matched your search

+140 -9
View File
@@ -10,15 +10,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 10,
"id": "2f2feca4-e0bf-4d68-af95-d3cfe5ac28bb", "id": "2f2feca4-e0bf-4d68-af95-d3cfe5ac28bb",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-03-23T14:17:57.955188Z", "iopub.execute_input": "2023-03-24T07:08:15.339494Z",
"iopub.status.busy": "2023-03-23T14:17:57.954638Z", "iopub.status.busy": "2023-03-24T07:08:15.338898Z",
"iopub.status.idle": "2023-03-23T14:17:58.563416Z", "iopub.status.idle": "2023-03-24T07:08:16.235510Z",
"shell.execute_reply": "2023-03-23T14:17:58.562686Z", "shell.execute_reply": "2023-03-24T07:08:16.233968Z",
"shell.execute_reply.started": "2023-03-23T14:17:57.955160Z" "shell.execute_reply.started": "2023-03-24T07:08:15.339445Z"
}, },
"tags": [] "tags": []
}, },
@@ -47,7 +47,11 @@
" person.setdefault(code, {})\n", " person.setdefault(code, {})\n",
" dict1 = {}\n", " dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 6).value\n", " dict1['name'] = sheet.cell(n, 6).value\n",
" dict1['sex'] = sheet.cell(n, 7).value\n", " if sheet.cell(n, 7).value ==1:\n",
" sex = '男'\n",
" else:\n",
" sex = '女'\n",
" dict1['sex'] = sex\n",
" dict1['unit'] = sheet.cell(n, 3).value\n", " dict1['unit'] = sheet.cell(n, 3).value\n",
"\n", "\n",
"\n", "\n",
@@ -66,6 +70,133 @@
"## 获取人员测试成绩" "## 获取人员测试成绩"
] ]
}, },
{
"cell_type": "code",
"execution_count": 12,
"id": "ab77e97a-de62-44dc-874e-72e9c8aaecf2",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-24T07:12:38.950011Z",
"iopub.status.busy": "2023-03-24T07:12:38.949468Z",
"iopub.status.idle": "2023-03-24T07:12:39.008067Z",
"shell.execute_reply": "2023-03-24T07:12:39.006932Z",
"shell.execute_reply.started": "2023-03-24T07:12:38.949964Z"
},
"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",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"#print(\"\\n运动项目信息:\")\n",
"filename = 'data/141.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": "c4107446-c0c6-4d76-9062-284ff806ec86",
"metadata": {},
"source": [
"## 导出测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "ee6db59f-dcc3-4a85-8dba-2e212c2b5be0",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-24T07:12:42.339250Z",
"iopub.status.busy": "2023-03-24T07:12:42.338673Z",
"iopub.status.idle": "2023-03-24T07:12:42.489449Z",
"shell.execute_reply": "2023-03-24T07:12:42.488377Z",
"shell.execute_reply.started": "2023-03-24T07:12:42.339201Z"
},
"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/东营石油工程设计院体测情况表.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", "cell_type": "code",
"execution_count": 10, "execution_count": 10,
@@ -151,7 +282,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@@ -165,7 +296,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.6" "version": "3.8.10"
} }
}, },
"nbformat": 4, "nbformat": 4,
+129
View File
@@ -0,0 +1,129 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "f501bde1-90cb-40c4-9dd4-533c27f81be5",
"metadata": {},
"source": [
"## 调查报告线下数据管理"
]
},
{
"cell_type": "markdown",
"id": "d31fa9b7-26d8-4101-94d1-f41723428aa9",
"metadata": {},
"source": [
"## 成年问卷导入"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc20aabb-3942-49b9-8841-8e8a0823033a",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/羊庙问卷统计表(成年组).xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"dict1 = {}\n",
"dict3 = {}\n",
"no_xinli = [108,389,268,270]\n",
"sheet = wb.active\n",
"data1 =list(sheet.values)\n",
"list_bh = data1[0][1:]\n",
"del data1[0]\n",
"print(len(list_bh))\n",
"for i in range(1,len(list_bh)+1):\n",
" list2 = []\n",
" \n",
" for item in data1:\n",
" list2.append(item[i])\n",
" dict1[list_bh[i-1]] = list2\n",
"for k, v in dict1.items():\n",
" if 0 in v:\n",
" print(k)\n"
]
},
{
"cell_type": "markdown",
"id": "75dda87e-804e-42ba-b1a4-08c8a8b65050",
"metadata": {},
"source": [
"## 老年问卷导入"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "09a354e6-a07a-40b8-9b8c-3499fb0b7c28",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/羊庙问卷统计表(老年组).xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"dict1 = {}\n",
"dict3 = {}\n",
"no_xinli = [286]\n",
"sheet = wb.active\n",
"data1 =list(sheet.values)\n",
"list_bh = data1[0][1:]\n",
"print(list_bh)\n",
"del data1[0]\n",
"print(len(list_bh))\n",
"for i in range(1,len(list_bh)+1):\n",
" list2 = []\n",
" \n",
" for item in data1:\n",
" list2.append(item[i])\n",
" dict1[list_bh[i-1]] = list2\n",
"for k, v in dict1.items():\n",
" if 0 in v or ' ' in v:\n",
" print(k)\n",
"print(dict1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10198e81-cea0-475a-bce7-4a4829320517",
"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
}