This commit is contained in:
512song committed 2022-04-24 19:47:07 +08:00
1 parent 753364ebab
commit 4b632ea887
2 files changed
+2161 -5

No files matched your search

+65
View File
@@ -330,6 +330,71 @@
" print('该单位已存在!')"
]
},
{
"cell_type": "markdown",
"id": "9e6fbf9c-3162-4597-9a62-d8ddc0295ffe",
"metadata": {},
"source": [
"### 长岭石化信息导入"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a89e8c88-2b22-4efd-a82e-e7f7bd0d28bd",
"metadata": {
"execution": {
"iopub.execute_input": "2022-04-24T10:38:29.567463Z",
"iopub.status.busy": "2022-04-24T10:38:29.566178Z",
"iopub.status.idle": "2022-04-24T10:38:31.198353Z",
"shell.execute_reply": "2022-04-24T10:38:31.195410Z",
"shell.execute_reply.started": "2022-04-24T10:38:29.567313Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"import pymongo\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"tice\"]\n",
"mycol = mydb[\"unit\"]\n",
"\n",
"name = '中国石油化工股份有限公司长岭分公司'\n",
"short_name = '长岭炼化'\n",
"myquery = {\"name\": name}\n",
"if mycol.find_one(myquery) is None:\n",
" wb = openpyxl.load_workbook('data/长岭.xlsx')\n",
" sheet = wb.active\n",
" # sheets = wb.sheetnames\n",
" depart = []\n",
" dict1 = {}\n",
" new_code = []\n",
" for n in range(2, sheet.max_row+1):\n",
" m_depart = sheet.cell(n,5).value\n",
" if m_depart not in depart:\n",
" depart.append(sheet.cell(n,5).value)\n",
" # print(sheet.cell(n,5).value)\n",
"\n",
" dict1['name'] = '中国石油化工股份有限公司长岭分公司'\n",
" dict1['short_name'] = '长岭炼化'\n",
" dict1['depart'] = depart\n",
" mycol.insert_one(dict1)\n",
" print('ok!')\n",
"else:\n",
" print('该单位已存在!')"
]
},
{
"cell_type": "markdown",
"id": "bf42e8af-a506-4e60-a661-b4281e3fef54",
+2096 -5
View File
File diff suppressed because it is too large. Load diff