This commit is contained in:
512song@sina.com committed 2022-06-16 15:19:28 +08:00
1 parent 803a0c5690
commit 1adfe9cc3d
2 files changed
+622 -500

No files matched your search

+157 -3
View File
@@ -3,8 +3,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"tags": [], "tags": []
"toc-hr-collapsed": true
}, },
"source": [ "source": [
"# 高考志愿管理" "# 高考志愿管理"
@@ -80,6 +79,161 @@
"\n" "\n"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2021年全国高等学校信息更新"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2021年全国高等学校信息导出至json文件"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"execution": {
"iopub.execute_input": "2022-06-15T07:00:27.890983Z",
"iopub.status.busy": "2022-06-15T07:00:27.890444Z",
"iopub.status.idle": "2022-06-15T07:00:28.430955Z",
"shell.execute_reply": "2022-06-15T07:00:28.429949Z",
"shell.execute_reply.started": "2022-06-15T07:00:27.890936Z"
},
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"filename = 'data/2021年全国普通高等学校名单.xlsx'\n",
"wb = openpyxl.load_workbook(filename)\n",
"sheet = wb.active\n",
"data1 =list(sheet.values)\n",
"del data1[0:3]\n",
"i = 1\n",
"dict1 = {}\n",
"for items in data1:\n",
" list1 = (items[1],str(items[2]),items[3],items[4],items[5],items[6])\n",
" dict1[i] = list1\n",
" i += 1 \n",
"with open('data/2021年全国普通高等学校名单.json','w') as fl2:\n",
" json.dump(dict1,fl2) \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 整理2021年全国高等学校信息"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"execution": {
"iopub.execute_input": "2022-06-15T08:26:50.903511Z",
"iopub.status.busy": "2022-06-15T08:26:50.902972Z",
"iopub.status.idle": "2022-06-15T08:26:50.972239Z",
"shell.execute_reply": "2022-06-15T08:26:50.971224Z",
"shell.execute_reply.started": "2022-06-15T08:26:50.903463Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"河北工业职业技术大学导入成功!\n",
"河北科技工程职业技术大学导入成功!\n",
"河北石油职业技术大学导入成功!\n",
"邢台应用技术职业学院导入成功!\n",
"山西工程科技职业大学导入成功!\n",
"吉林通用航空职业技术学院导入成功!\n",
"通化医药健康职业学院导入成功!\n",
"上海南湖职业技术学院导入成功!\n",
"浙江药科职业大学导入成功!\n",
"浙江金华科贸职业技术学院导入成功!\n",
"宿州航空职业学院导入成功!\n",
"和君职业学院导入成功!\n",
"滨州科技职业学院导入成功!\n",
"洛阳文化旅游职业学院导入成功!\n",
"周口文理职业学院导入成功!\n",
"信阳艺术职业学院导入成功!\n",
"郑州城建职业学院导入成功!\n",
"郑州医药健康职业学院导入成功!\n",
"湖北孝感美珈职业学院导入成功!\n",
"广州幼儿师范高等专科学校导入成功!\n",
"广东汕头幼儿师范高等专科学校导入成功!\n",
"广东梅州职业技术学院导入成功!\n",
"广东潮州卫生健康职业学院导入成功!\n",
"广东云浮中医药职业学院导入成功!\n",
"广东肇庆航空职业学院导入成功!\n",
"广西农业职业技术大学导入成功!\n",
"防城港职业技术学院导入成功!\n",
"广西信息职业技术学院导入成功!\n",
"广西农业工程职业技术学院导入成功!\n",
"北海康养职业学院导入成功!\n",
"重庆工信职业学院导入成功!\n",
"甘孜职业学院导入成功!\n",
"自贡职业技术学院导入成功!\n",
"贵阳康养职业大学导入成功!\n",
"贵州文化旅游职业学院导入成功!\n",
"宝鸡中北职业学院导入成功!\n",
"兰州石化职业技术大学导入成功!\n",
"兰州资源环境职业技术大学导入成功!\n",
"兰州航空职业技术学院导入成功!\n",
"白银希望职业技术学院导入成功!\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"import pymongo\n",
"\n",
"\n",
"filename = 'data/2021年全国普通高等学校名单.json'\n",
"with open(filename,'r') as fl:\n",
" m_xx = json.load(fl)\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"gaokao\"]\n",
"mycol = mydb[\"college_2021\"]\n",
"\n",
"m_col = {}\n",
"\n",
"\n",
"for x in mycol.find({\"id_code\":{'$exists': 'true'}},{\"_id\": 0, \"id_code\": 1, \"name\": 1}):\n",
" m_col[x['id_code']] = x['name']\n",
"#print(m_col.keys())\n",
"for k, v in m_xx.items():\n",
" m_code = v[1]\n",
" #print(m_code)\n",
" if m_code not in m_col.keys():\n",
" dict1 = {}\n",
" dict1['id_code'] = v[1]\n",
" dict1['name'] = v[0]\n",
" dict1['charge'] = v[2]\n",
" dict1['city'] = v[3]\n",
" dict1['grade'] = v[4]\n",
" dict1['note'] = v[5]\n",
" mycol.insert_one(dict1) \n",
" print(dict1['name'] + '导入成功!')\n",
" #print(v[0],v[1])\n",
" \n",
"\n",
"\n",
" "
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
@@ -602,7 +756,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
+465 -497
View File
File diff suppressed because it is too large. Load diff