删除 体测单位/.ipynb_checkpoints/体测数据管理-checkpoint.ipynb
This commit is contained in:
1 parent
b1332cc60f
commit
83e5aa4218
1 file changed
-166
@@ -1,166 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "dcfbd41f-ca70-4f15-9153-60e6aaac27e8",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 生成手机验证码"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "b68302b4-8fc1-4060-a10d-7f059f006f3c",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-07-11T11:45:00.310196Z",
|
||||
"iopub.status.busy": "2023-07-11T11:45:00.309336Z",
|
||||
"iopub.status.idle": "2023-07-11T11:45:00.344527Z",
|
||||
"shell.execute_reply": "2023-07-11T11:45:00.343903Z",
|
||||
"shell.execute_reply.started": "2023-07-11T11:45:00.310155Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"54\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import os,sys,shutil\n",
|
||||
"import json\n",
|
||||
"import math\n",
|
||||
"import glob\n",
|
||||
"import random\n",
|
||||
"from pathlib import Path\n",
|
||||
"import pymongo\n",
|
||||
"\n",
|
||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||
"mydb = myclient[\"baogao\"]\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/北京石油分公司报告明细.xlsx')\n",
|
||||
"place_id = 419309\n",
|
||||
"dw_name = '北京石油分公司'\n",
|
||||
"fi_path = 'file/2023-06-15'\n",
|
||||
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||||
"\n",
|
||||
"code_list = []\n",
|
||||
"for i in range(10): # 0~9\n",
|
||||
" code_list.append(str(i))\n",
|
||||
" \n",
|
||||
"list1 = []\n",
|
||||
"i = 0\n",
|
||||
"while i < len(fls):\n",
|
||||
" code = random.sample(code_list,6) #随机取6位数\n",
|
||||
" code_num = ''.join(code)\n",
|
||||
" if code_num not in list1:\n",
|
||||
" list1.append(code_num)\n",
|
||||
" i +=1\n",
|
||||
"print(len(list1))\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"list2 = []\n",
|
||||
"i = 0\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" if sheet.cell(n,1).value is not None:\n",
|
||||
" dict1 = {}\n",
|
||||
" phone = str(sheet.cell(n, 3).value)\n",
|
||||
" code = int(sheet.cell(n, 1).value)\n",
|
||||
" yzm = list1[i]\n",
|
||||
" i+=1\n",
|
||||
" dict1 = {'place_id':place_id,'code':yzm,'fn':str(code)+'.pdf'}\n",
|
||||
" list2.append(dict1)\n",
|
||||
"mycol = mydb[\"pdf\"]\n",
|
||||
"x = mycol.insert_many(list2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "a0a7cb45-4357-47a1-9094-e1500d072561",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-07-11T10:33:27.193601Z",
|
||||
"iopub.status.busy": "2023-07-11T10:33:27.192748Z",
|
||||
"iopub.status.idle": "2023-07-11T10:33:27.223006Z",
|
||||
"shell.execute_reply": "2023-07-11T10:33:27.221929Z",
|
||||
"shell.execute_reply.started": "2023-07-11T10:33:27.193559Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"54\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import os,sys,shutil\n",
|
||||
"import json\n",
|
||||
"import math\n",
|
||||
"import glob\n",
|
||||
"import random\n",
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/北京石油分公司报告明细.xlsx')\n",
|
||||
"place_id = 1\n",
|
||||
"dw_name = '北京石油分公司'\n",
|
||||
"fi_path = 'file/2023-06-15'\n",
|
||||
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||||
"\n",
|
||||
"code_list = []\n",
|
||||
"for i in range(10): # 0~9\n",
|
||||
" code_list.append(str(i))\n",
|
||||
" \n",
|
||||
"list1 = []\n",
|
||||
"i = 0\n",
|
||||
"while i < len(fls):\n",
|
||||
" code = random.sample(code_list,6) #随机取6位数\n",
|
||||
" code_num = ''.join(code)\n",
|
||||
" if code_num not in list1:\n",
|
||||
" list1.append(code_num)\n",
|
||||
" i +=1\n",
|
||||
"print(len(list1))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f3311070-2b8d-4442-b7da-025e48ee7bd3",
|
||||
"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
|
||||
}
|
||||
Reference in new issue
Block a user