This commit is contained in:
512song@sina.com committed 2023-08-11 07:43:01 +08:00
1 parent 8e449c63b3
commit 24a9839483
2 files changed
+270 -29

No files matched your search

+187 -17
View File
@@ -1299,26 +1299,11 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-08-04T03:53:00.735786Z",
"iopub.status.busy": "2022-08-04T03:53:00.735257Z",
"iopub.status.idle": "2022-08-04T03:53:10.194351Z",
"shell.execute_reply": "2022-08-04T03:53:10.192776Z",
"shell.execute_reply.started": "2022-08-04T03:53:00.735737Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import pymysql\n",
"import pymongo\n",
@@ -1376,6 +1361,191 @@
"print('ok')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 导入2023年录取数据"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 导入2023年一分一段表"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('./data/2023年一分一段表.xlsx')\n",
"sheet = wb.active\n",
"i = 1\n",
"dict1 = {}\n",
"for n in range(4,sheet.max_row):\n",
" m_score = sheet.cell(n,1).value\n",
" m_num = sheet.cell(n,2).value\n",
" m_sum = sheet.cell(n,3).value\n",
" m_max = m_sum - m_num + 1\n",
" dict1[m_score] = {'num_person':m_num,'max_rank':m_max,'min_rank':m_sum}\n",
"filename = 'data/2023年一分一段表.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1,fl) \n"
]
},
{
"cell_type": "markdown",
"metadata": {
"execution": {
"iopub.execute_input": "2023-07-26T13:07:34.650896Z",
"iopub.status.busy": "2023-07-26T13:07:34.650369Z",
"iopub.status.idle": "2023-07-26T13:07:34.656873Z",
"shell.execute_reply": "2023-07-26T13:07:34.655204Z",
"shell.execute_reply.started": "2023-07-26T13:07:34.650847Z"
}
},
"source": [
"### 导出2023年录取数据并生成分数"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"filename = 'data/2023年一分一段表.json'\n",
"with open(filename,'r') as fl:\n",
" m_xx = json.load(fl)\n",
"\n",
"for k, v in m_xx.items():\n",
" list1 = []\n",
" list1 = (v['min_rank'],v['max_rank'])\n",
" yfyd[int(k)] = list1\n",
"dict1 = {}\n",
"filename = 'data/山东省2023年普通类常规批第1次志愿投档情况表.xlsx'\n",
"wb = openpyxl.load_workbook(filename)\n",
"sheet = wb.active\n",
"data1 =list(sheet.values)\n",
"del data1[0:2]\n",
"m_num = 1\n",
"i = 1\n",
"for items in data1:\n",
" m_rank = items[3] \n",
" list1 = []\n",
" print(items[0])\n",
" for k, v in yfyd.items():\n",
" if m_rank >=v[1] and m_rank <=v[0]:\n",
" m_num = int(k)\n",
" break\n",
" list1 = (items[0],items[1],items[2],items[3],m_num)\n",
" dict1[i] = list1\n",
" i += 1 \n",
"with open('data/2023.json','w') as fl2:\n",
" json.dump(dict1,fl2) \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2023年专业录取分数及位次"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"execution": {
"iopub.execute_input": "2023-07-26T14:40:10.969625Z",
"iopub.status.busy": "2023-07-26T14:40:10.969096Z",
"iopub.status.idle": "2023-07-26T14:40:29.882965Z",
"shell.execute_reply": "2023-07-26T14:40:29.881763Z",
"shell.execute_reply.started": "2023-07-26T14:40:10.969577Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n",
"ok\n"
]
}
],
"source": [
"import json\n",
"import pymongo\n",
"import decimal\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"gaokao\"]\n",
"mycol1 = mydb[\"admission_ls\"]\n",
"mycol = mydb[\"admission_2023\"]\n",
"\n",
"m_col = {}\n",
"m_spe = {}\n",
"m_xx = {}\n",
"filename = 'data/2023.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"for k, v in dict1.items():\n",
" m_xx = {}\n",
" m_xx['col_code'] = v[1][:4]\n",
" m_xx['col_name'] = v[1][4:]\n",
" m_xx['spe_code'] = v[0][:2]\n",
" m_xx['spe_name'] = v[0][2:]\n",
" m_xx['plan'] = v[2]\n",
" m_xx['num_min'] = v[4] \n",
" m_xx['rank_min'] = v[3]\n",
" m_xx['nian'] = '2023'\n",
" mycol1.insert_one(m_xx)\n",
" #print(m_xx)\n",
"print('ok')\n",
"mydoc = mycol1.find().sort(\"rank_min\")\n",
"i = 1 \n",
"for x in mydoc:\n",
" m_xx = {}\n",
" m_xx['pos'] = i\n",
" m_xx['col_code'] = x['col_code']\n",
" m_xx['col_name'] = x['col_name'] \n",
" m_xx['spe_code'] = x['spe_code']\n",
" m_xx['spe_name'] = x['spe_name']\n",
" m_xx['plan'] = x['plan']\n",
" m_xx['num_min'] = x['num_min']\n",
" m_xx['rank_min'] = x['rank_min']\n",
" m_xx['nian'] = '2023'\n",
" mycol.insert_one(m_xx)\n",
" i+=1\n",
"print('ok') "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {