This commit is contained in:
512song committed 2023-03-23 15:11:08 +00:00
1 parent 1000a8f2ea
commit d30e4b0ca7
2 files changed
+509 -64

No files matched your search

@@ -0,0 +1,173 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "28695364-38de-442e-818d-cfab45902763",
"metadata": {},
"source": [
"## 导入人员信息"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2f2feca4-e0bf-4d68-af95-d3cfe5ac28bb",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-23T14:17:57.955188Z",
"iopub.status.busy": "2023-03-23T14:17:57.954638Z",
"iopub.status.idle": "2023-03-23T14:17:58.563416Z",
"shell.execute_reply": "2023-03-23T14:17:58.562686Z",
"shell.execute_reply.started": "2023-03-23T14:17:57.955160Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/student_20140922(东营工程设计院监测花名册2023年) .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",
" dict1['sex'] = sheet.cell(n, 7).value\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
"\n",
"\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": "76caa442-de4f-41eb-8743-b4a9d6c749d0",
"metadata": {},
"source": [
"## 获取人员测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "579fd3c1-7fe3-49ef-8875-0d823b7d0546",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-23T14:30:43.407552Z",
"iopub.status.busy": "2023-03-23T14:30:43.406666Z",
"iopub.status.idle": "2023-03-23T14:30:43.479839Z",
"shell.execute_reply": "2023-03-23T14:30:43.478772Z",
"shell.execute_reply.started": "2023-03-23T14:30:43.407511Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"338\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\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,a.date_joined FROM places_result AS a,_tianjin AS b WHERE a.place_id=134 AND a.avatar_id=b.id\n",
"filename = 'data/东营工程设计院人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"\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",
"dict3 = {}\n",
"for result in list1:\n",
" user = result[2]\n",
" if user in dict2.keys():\n",
" dict3.setdefault(user,{}) \n",
" dict3[user]['name'] = dict2[user]['name']\n",
" dict3[user]['unit'] = dict2[user]['unit']\n",
"\n",
"print(len(dict3))\n",
"list1 = []\n",
"for k, v in dict3.items():\n",
" list2 = [k,v['name'],v['unit']]\n",
" list1.append(list2)\n",
"filename = 'data/东营工程设计院参加测试人员情况表.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d3647aa-9f06-4a96-9d60-690d61b1a384",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}