20240920
This commit is contained in:
1 parent
63f678daf4
commit
96f043313c
4 files changed
+445
-670
No files matched your search
+12
-395
@@ -61,7 +61,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"source": [
|
||||
"## 获取人员测试成绩"
|
||||
]
|
||||
@@ -176,7 +178,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d034a61d-1fbd-417b-99bd-277e43ebb678",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"source": [
|
||||
"## 导出测试人员信息"
|
||||
]
|
||||
@@ -248,7 +252,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d794e69d-9444-4765-9b7d-8dcb0f8c4343",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"source": [
|
||||
"## 导入问卷信息"
|
||||
]
|
||||
@@ -378,7 +384,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9f9111f1-8cf0-4d45-b9b2-e3b631023581",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"source": [
|
||||
"## 获取问卷人员信息"
|
||||
]
|
||||
@@ -557,397 +565,6 @@
|
||||
"## 核对人员成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ee84a3ce-deb7-4345-a4a4-877872996e1c",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['bmi','lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||
"bmi = ['height','weight']\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/727410_pdf.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" list2 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/result_东营老年大学1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
" \n",
|
||||
"\n",
|
||||
"for xm in list2: \n",
|
||||
" id = xm['id']\n",
|
||||
" if str(id) in dict1.keys():\n",
|
||||
" #print(id,xm['name'])\n",
|
||||
" for item in xm['fits'].keys():\n",
|
||||
" y_score = xm['fits'][item]['score']\n",
|
||||
" if item not in dict1[str(id)].keys() or y_score != dict1[str(id)][item]['score']:\n",
|
||||
" print(id,xm['name'],item,'no')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e76ef95a-25dc-45f2-8b8c-617acbf546c1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 更新人员手机号码"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "37e24019-9b79-4748-ae6a-2bdb6052862d",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"filename = 'data/东营老年大学.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/东营老年大学电话.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" code = str(sheet.cell(n, 3).value)\n",
|
||||
" phone = sheet.cell(n, 1).value\n",
|
||||
" if code in dict1.keys():\n",
|
||||
" print(phone,code,dict1[code]['phone'])\n",
|
||||
" dict1[code]['phone'] = phone\n",
|
||||
" \n",
|
||||
" \n",
|
||||
"filename = 'data/东营老年大学.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7ac62aed-6256-4bd2-a563-5f6e34504121",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 核对人员手机号码"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "42b7cd7d-3446-4abf-91f2-c85d447231e9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"filename = 'data/东营老年大学.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/6.20日北体花名册.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"dict2 = {}\n",
|
||||
"\n",
|
||||
"for n in range(3, sheet.max_row+1):\n",
|
||||
" phone = int(sheet.cell(n, 3).value)\n",
|
||||
" \n",
|
||||
" dict2[phone] = sheet.cell(n, 2).value\n",
|
||||
"i = 1\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" if 'phone' in v.keys() and v['phone'] in dict2.keys() :\n",
|
||||
" print(i,v['name'],dict2[v['phone']])\n",
|
||||
" i+=1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "bd4b91e9-289c-4f21-aab6-846b5f98c493",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%reset -f\n",
|
||||
"\n",
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/东营老年大学.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"dict2 = {}\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" dict2[v['phone']] = v['name']\n",
|
||||
"wb = openpyxl.load_workbook('data/6.20日北体花名册.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"for n in range(3, sheet.max_row+1):\n",
|
||||
" phone = int(sheet.cell(n, 3).value)\n",
|
||||
" if phone not in dict2.keys():\n",
|
||||
" print(sheet.cell(n, 2).value)\n",
|
||||
" \n",
|
||||
"print(dict2) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "dacbf0e8-f456-478f-8253-2824d68d092c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 合并分日测试信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"id": "162364f8-8ae9-4bbb-8fb1-e9181ececf02",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-14T12:37:55.393433Z",
|
||||
"iopub.status.busy": "2024-09-14T12:37:55.392657Z",
|
||||
"iopub.status.idle": "2024-09-14T12:37:55.424141Z",
|
||||
"shell.execute_reply": "2024-09-14T12:37:55.423583Z",
|
||||
"shell.execute_reply.started": "2024-09-14T12:37:55.393359Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"170\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"filename = 'data/result_北体体质康健1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"filename = 'data/result_北体体质康健2.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"\n",
|
||||
"n = 50\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" dict1[n+int(k)] = v\n",
|
||||
" \n",
|
||||
"filename = 'data/result_北体体质康健.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False) \n",
|
||||
"print(len(dict1))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ddda3101-052a-45c5-87af-65333b4ba141",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 补充问卷人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"id": "8e025cb5-8c9f-4eb9-a66e-863df32881c8",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-14T12:37:09.151657Z",
|
||||
"iopub.status.busy": "2024-09-14T12:37:09.150889Z",
|
||||
"iopub.status.idle": "2024-09-14T12:37:09.186568Z",
|
||||
"shell.execute_reply": "2024-09-14T12:37:09.186032Z",
|
||||
"shell.execute_reply.started": "2024-09-14T12:37:09.151586Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/北体体质康健.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"filename = 'data/result_北体体质康健.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"filename = 'data/北体体质康健.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"for n in range(1, sheet.max_row+1):\n",
|
||||
" code = str(sheet.cell(n, 1).value)\n",
|
||||
" if code in dict1.keys(): \n",
|
||||
" if sheet.cell(n,5).value is not None:\n",
|
||||
" dict1[code]['phone'] = str(sheet.cell(n,5).value)\n",
|
||||
" else:\n",
|
||||
" dict1[code]= dict2[code]\n",
|
||||
" rq = '2024-09-14'\n",
|
||||
" birth = dict2[code]['birth']\n",
|
||||
" days = (rq-birth).days \n",
|
||||
" dict1[code]['age'] = int(days/365)\n",
|
||||
" dict1[code]['month'] = int(days/365*12)\n",
|
||||
" \n",
|
||||
"filename = 'data/result_北体体质康健.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"id": "ef75192e-a6ec-4d72-88b4-7645ce6d0aed",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-14T12:43:31.977618Z",
|
||||
"iopub.status.busy": "2024-09-14T12:43:31.976867Z",
|
||||
"iopub.status.idle": "2024-09-14T12:43:31.999628Z",
|
||||
"shell.execute_reply": "2024-09-14T12:43:31.999148Z",
|
||||
"shell.execute_reply.started": "2024-09-14T12:43:31.977549Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"filename = 'data/result_北体体质康健2.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" if 'month' not in v.keys():\n",
|
||||
" rq = date.fromisoformat(v['rq'])\n",
|
||||
" birth = date.fromisoformat(v['birth'])\n",
|
||||
" days = (rq-birth).days \n",
|
||||
" dict1[k]['age'] = int(days/365)\n",
|
||||
" dict1[k]['month'] = int(days/365*12)\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||
"print('ok') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"id": "99c612c8-aa47-4ed8-b866-c8d2edcaea4b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-14T12:45:56.907974Z",
|
||||
"iopub.status.busy": "2024-09-14T12:45:56.907231Z",
|
||||
"iopub.status.idle": "2024-09-14T12:46:35.198207Z",
|
||||
"shell.execute_reply": "2024-09-14T12:46:35.197069Z",
|
||||
"shell.execute_reply.started": "2024-09-14T12:45:56.907903Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"79\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"headers = {\n",
|
||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||
" }\n",
|
||||
"filename = 'data/result_北体体质康健2.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"file_path ='./北体体质康健班/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i=0\n",
|
||||
"list2 = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list1 = []\n",
|
||||
" mydata = {}\n",
|
||||
" \n",
|
||||
" id = str(k).rjust(4,\"0\")\n",
|
||||
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
|
||||
" mydata['title'] = '北体体质康健班'\n",
|
||||
" mydata['subtitle'] = ''\n",
|
||||
" mydata['id'] = id\n",
|
||||
" mydata['name'] = v['name']\n",
|
||||
" if v['sex'] == '男':\n",
|
||||
" mydata['gender'] = 'male'\n",
|
||||
" else:\n",
|
||||
" mydata['gender'] = 'female'\n",
|
||||
" \n",
|
||||
" mydata['month'] = v['month']\n",
|
||||
" mydata['fits'] = {}\n",
|
||||
" survey_list = ['tcm','psy','spine']\n",
|
||||
" for item in survey_list:\n",
|
||||
" if item in v.keys():\n",
|
||||
" mydata.setdefault('surveys',{})\n",
|
||||
" mydata['surveys'][item] = v[item]\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" #mydata['fits'] = {}\n",
|
||||
" for item in list_item:\n",
|
||||
" if item in v.keys():\n",
|
||||
" mydata.setdefault('fits',{})\n",
|
||||
" if item in ['lung','pushup','step','situp']:\n",
|
||||
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
||||
" else:\n",
|
||||
" mark = v[item]['成绩'].split()[0]\n",
|
||||
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
|
||||
" if len(mydata['fits']) >2 : \n",
|
||||
" list1.append(mydata)\n",
|
||||
" list2.append([k,v['name']])\n",
|
||||
" i+=1\n",
|
||||
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||||
" #print(id,v['name'],x.text)\n",
|
||||
" #print(mydata)\n",
|
||||
" #x.close()\n",
|
||||
"print(i)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
+32
-206
@@ -23,10 +23,10 @@
|
||||
"mydb = myclient[\"baogao\"]\n",
|
||||
"mycol = mydb[\"place\"]\n",
|
||||
"\n",
|
||||
"place_id = 698465\n",
|
||||
"place_code = \"06\"\n",
|
||||
"dw_name = \"天宫院社区\"\n",
|
||||
"dw_jc = \"天宫院社区\"\n",
|
||||
"place_id = 727411\n",
|
||||
"place_code = \"13\"\n",
|
||||
"dw_name = \"北体体质康健班\"\n",
|
||||
"dw_jc = \"北体体质康健班\"\n",
|
||||
"myquery = { \"id\": place_id }\n",
|
||||
"num = mycol.count_documents(myquery)\n",
|
||||
"if num>0:\n",
|
||||
@@ -46,26 +46,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": null,
|
||||
"id": "6ce2cbc7-435a-461c-bdb8-abd9a6962fbc",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-08-11T11:24:39.665184Z",
|
||||
"iopub.status.busy": "2024-08-11T11:24:39.664256Z",
|
||||
"iopub.status.idle": "2024-08-11T11:24:39.691000Z",
|
||||
"shell.execute_reply": "2024-08-11T11:24:39.690127Z",
|
||||
"shell.execute_reply.started": "2024-08-11T11:24:39.665085Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import os,sys,shutil\n",
|
||||
@@ -79,10 +63,10 @@
|
||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||
"mydb = myclient[\"baogao\"]\n",
|
||||
"\n",
|
||||
"place_id = 698465\n",
|
||||
"place_code = \"06\"\n",
|
||||
"dw_name = \"淄博积家村\"\n",
|
||||
"dw_jc = \"淄博积家村\"\n",
|
||||
"place_id = 727411\n",
|
||||
"place_code = \"13\"\n",
|
||||
"dw_name = \"北体体质康健班\"\n",
|
||||
"dw_jc = \"北体体质康健班\"\n",
|
||||
"fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n",
|
||||
"fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n",
|
||||
"\n",
|
||||
@@ -113,53 +97,13 @@
|
||||
" #fi_name =Path(fn).stem\n",
|
||||
" code = int(fi_name)\n",
|
||||
" dxm = list1[i]\n",
|
||||
" dict2 = {'place_id':place_id,'code':dxm,'fn':Path(fn).name,'rq':'20240811'}\n",
|
||||
" dict2 = {'place_id':place_id,'code':dxm,'fn':Path(fn).name,'rq':'20240914'}\n",
|
||||
" list2.append(dict2)\n",
|
||||
" i +=1\n",
|
||||
"x = mycol.insert_many(list2)\n",
|
||||
"print('ok') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1ca065ca-d999-4e3f-841b-16f9666b6975",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"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",
|
||||
"place_id = 727410\n",
|
||||
"place_code = \"08\"\n",
|
||||
"dw_name = \"北体体质康健实验班\"\n",
|
||||
"dw_jc = \"北体体质康健实验班\"\n",
|
||||
"fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n",
|
||||
"fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n",
|
||||
"\n",
|
||||
"code_list = []\n",
|
||||
"for i in range(10): # 0~9\n",
|
||||
" code_list.append(str(i))\n",
|
||||
"list1 = []\n",
|
||||
"mycol = mydb[\"pdf\"]\n",
|
||||
"query1 = { \"place_id\": place_id }\n",
|
||||
"list2 = []\n",
|
||||
"mydoc = mycol.find(query1,{ \"code\": 1, \"_id\": 0 })\n",
|
||||
"\n",
|
||||
"for x in mydoc:\n",
|
||||
" list2.append(x['code'])\n",
|
||||
"print(list2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ad9e943a-bb3a-4d58-93ef-cc442a80effa",
|
||||
@@ -170,64 +114,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": null,
|
||||
"id": "5f665c0f-8d30-4759-b7f8-fb7e13b98efa",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-08-11T11:26:41.537017Z",
|
||||
"iopub.status.busy": "2024-08-11T11:26:41.536326Z",
|
||||
"iopub.status.idle": "2024-08-11T11:26:41.562731Z",
|
||||
"shell.execute_reply": "2024-08-11T11:26:41.561622Z",
|
||||
"shell.execute_reply.started": "2024-08-11T11:26:41.536952Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"5 no phone\n",
|
||||
"22 no phone\n",
|
||||
"19 no phone\n",
|
||||
"38 no phone\n",
|
||||
"25 no phone\n",
|
||||
"6 no phone\n",
|
||||
"8 no phone\n",
|
||||
"26 no phone\n",
|
||||
"15 no phone\n",
|
||||
"13 no phone\n",
|
||||
"20 no phone\n",
|
||||
"23 no phone\n",
|
||||
"27 no phone\n",
|
||||
"10 no phone\n",
|
||||
"21 no phone\n",
|
||||
"3 no phone\n",
|
||||
"30 no phone\n",
|
||||
"11 no phone\n",
|
||||
"14 no phone\n",
|
||||
"24 no phone\n",
|
||||
"1 15153309038 9-曹秀芹.pdf\n",
|
||||
"2 13573332133 17-段玉华.pdf\n",
|
||||
"3 13964491825 7-韩美华.pdf\n",
|
||||
"4 15553344004 1-张爱英.pdf\n",
|
||||
"5 15853389189 36-袁会富.pdf\n",
|
||||
"6 15069350919 16-王芹英.pdf\n",
|
||||
"7 15165846001 2-张俊华.pdf\n",
|
||||
"8 13070650793 18-肖翠花.pdf\n",
|
||||
"9 13455364491 35-王霞.pdf\n",
|
||||
"10 15853380767 28-肖爱英.pdf\n",
|
||||
"11 13646430765 29-梁桂岭.pdf\n",
|
||||
"12 13053316892 12-孙宗玲.pdf\n",
|
||||
"13 13287885248 31-杜婷.pdf\n",
|
||||
"14 13153385772 32-崔杰.pdf\n",
|
||||
"15 15169224472 33-姚桂银.pdf\n",
|
||||
"16 13583398468 4-尚永.pdf\n",
|
||||
"17 18653305998 37-李琳.pdf\n",
|
||||
"18 13869390557 34-徐爱锋.pdf\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from tencentcloud.common import credential\n",
|
||||
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||
@@ -241,13 +133,13 @@
|
||||
"mydb = myclient[\"baogao\"]\n",
|
||||
"mycol = mydb[\"pdf\"]\n",
|
||||
"\n",
|
||||
"dw_jc = \"淄博积家村测试者\"\n",
|
||||
"filename = 'data/积家基础数据2408.json'\n",
|
||||
"dw_jc = \"北体体质康健班\"\n",
|
||||
"filename = 'data/北体体质康健.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"dict2 = {}\n",
|
||||
"#place_id = 571315\n",
|
||||
"myquery = { \"place_id\": place_id,\"rq\":'20240811' }\n",
|
||||
"myquery = { \"place_id\": place_id,\"rq\":'20240914' }\n",
|
||||
"for x in mycol.find(myquery,{ \"_id\": 0, \"place_id\": 0}):\n",
|
||||
" code = int(x['fn'].split('-')[0])\n",
|
||||
" if str(code) in dict1.keys() and 'phone' in dict1[str(code)].keys():\n",
|
||||
@@ -302,64 +194,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": null,
|
||||
"id": "4b2b5d76-665f-4dfe-bbd3-5c80abd8c3e3",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-08-11T11:28:21.443578Z",
|
||||
"iopub.status.busy": "2024-08-11T11:28:21.442841Z",
|
||||
"iopub.status.idle": "2024-08-11T11:28:25.277992Z",
|
||||
"shell.execute_reply": "2024-08-11T11:28:25.276474Z",
|
||||
"shell.execute_reply.started": "2024-08-11T11:28:21.443507Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"no phone\n",
|
||||
"15153309038 send success\n",
|
||||
"13573332133 send success\n",
|
||||
"13964491825 send success\n",
|
||||
"15553344004 send success\n",
|
||||
"15853389189 send success\n",
|
||||
"15069350919 send success\n",
|
||||
"15165846001 send success\n",
|
||||
"13070650793 send success\n",
|
||||
"13455364491 send success\n",
|
||||
"15853380767 send success\n",
|
||||
"13646430765 send success\n",
|
||||
"13053316892 send success\n",
|
||||
"13287885248 send success\n",
|
||||
"13153385772 send success\n",
|
||||
"15169224472 send success\n",
|
||||
"13583398468 send success\n",
|
||||
"18653305998 send success\n",
|
||||
"13869390557 send success\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from tencentcloud.common import credential\n",
|
||||
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||
@@ -368,18 +208,19 @@
|
||||
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
||||
"import json\n",
|
||||
"import pymongo\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||
"mydb = myclient[\"baogao\"]\n",
|
||||
"mycol = mydb[\"pdf\"]\n",
|
||||
"\n",
|
||||
"dw_jc = \"淄博积家村测试者\"\n",
|
||||
"filename = 'data/积家基础数据2408.json'\n",
|
||||
"dw_jc = \"北体体质康健班测试者\"\n",
|
||||
"filename = 'data/北体体质康健.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"dict2 = {}\n",
|
||||
"#place_id = 571315\n",
|
||||
"myquery = { \"place_id\": place_id,\"rq\":'20240811' }\n",
|
||||
"myquery = { \"place_id\": place_id,\"rq\":'20240914' }\n",
|
||||
"for x in mycol.find(myquery,{ \"_id\": 0, \"place_id\": 0}):\n",
|
||||
" code = int(x['fn'].split('-')[0])\n",
|
||||
" if str(code) in dict1.keys() and 'phone' in dict1[str(code)].keys():\n",
|
||||
@@ -387,7 +228,7 @@
|
||||
" else:\n",
|
||||
" print('no phone')\n",
|
||||
"#print(dict2)\n",
|
||||
"dw_jc = \"世纪花园测试者\"\n",
|
||||
"#dw_jc = \"北体体质康健班测试者\"\n",
|
||||
"#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" phone = '+86'+v['phone']\n",
|
||||
@@ -416,8 +257,8 @@
|
||||
" req.SenderId = \"\"\n",
|
||||
" resp = client.SendSms(req)\n",
|
||||
" dict3 = json.loads(resp.to_json_string(indent=2))\n",
|
||||
"\n",
|
||||
" print(v['phone'],dict3['SendStatusSet'][0][\"Message\"])\n",
|
||||
" time.sleep(2)\n",
|
||||
" except TencentCloudSDKException as err:\n",
|
||||
" print(v['phone'],err)"
|
||||
]
|
||||
@@ -443,27 +284,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": null,
|
||||
"id": "25a269c3-758f-4e79-ae6d-a6e6f161d64b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-08-11T10:49:44.708154Z",
|
||||
"iopub.status.busy": "2024-08-11T10:49:44.707426Z",
|
||||
"iopub.status.idle": "2024-08-11T10:49:44.956435Z",
|
||||
"shell.execute_reply": "2024-08-11T10:49:44.954940Z",
|
||||
"shell.execute_reply.started": "2024-08-11T10:49:44.708083Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"+8613793180751 send success\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from tencentcloud.common import credential\n",
|
||||
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||
@@ -477,12 +303,12 @@
|
||||
"mydb = myclient[\"baogao\"]\n",
|
||||
"mycol = mydb[\"pdf\"]\n",
|
||||
"\n",
|
||||
"filename = 'data/世纪花园基础数据240808.json'\n",
|
||||
"filename = 'data/北体体质康健.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"dict2 = {}\n",
|
||||
"#place_id = 571315\n",
|
||||
"myquery = { \"place_id\": place_id,\"rq\":'20240811' }\n",
|
||||
"myquery = { \"place_id\": place_id,\"rq\":'20240914' }\n",
|
||||
"for x in mycol.find(myquery,{ \"_id\": 0, \"place_id\": 0}):\n",
|
||||
" code = int(x['fn'].split('-')[0])\n",
|
||||
" if str(code) in dict1.keys() and 'phone' in dict1[str(code)].keys():\n",
|
||||
@@ -490,10 +316,10 @@
|
||||
" else:\n",
|
||||
" print('no phone')\n",
|
||||
"#print(dict2)\n",
|
||||
"dw_jc = \"世纪花园测试者\"\n",
|
||||
"dw_jc = \"北体体质康健班测试者\"\n",
|
||||
"\n",
|
||||
"phone = '+86'+'13793180751'\n",
|
||||
"yzm = '05403'\n",
|
||||
"phone = '+86'+'18854609676'\n",
|
||||
"yzm = '13306'\n",
|
||||
"try: \n",
|
||||
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
||||
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
||||
|
||||
+396
@@ -0,0 +1,396 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "338fb8da-815a-4536-ae91-4f461ba9401f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 体测人员导入"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"id": "ba24132c-133f-4508-8fe7-e68d1908b6e9",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-20T08:47:18.577809Z",
|
||||
"iopub.status.busy": "2024-09-20T08:47:18.577022Z",
|
||||
"iopub.status.idle": "2024-09-20T08:47:18.914709Z",
|
||||
"shell.execute_reply": "2024-09-20T08:47:18.914113Z",
|
||||
"shell.execute_reply.started": "2024-09-20T08:47:18.577734Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/镇海体质监测报名.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" code = int(sheet.cell(n, 1).value)\n",
|
||||
" person.setdefault(code, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||||
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||||
" dict1['unit'] = sheet.cell(n, 7).value\n",
|
||||
" dict1['gh'] = sheet.cell(n, 5).value\n",
|
||||
" dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0] \n",
|
||||
" dict1['phone'] = str(sheet.cell(n,4).value)\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": "10ddfd3b-697c-4459-8bed-147b22f88239",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 生成读卡系统文件"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "63ab2d5b-3a0a-4ac7-a3e7-b3a34e621e98",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-17T01:49:44.352863Z",
|
||||
"iopub.status.busy": "2024-09-17T01:49:44.352020Z",
|
||||
"iopub.status.idle": "2024-09-17T01:49:44.374799Z",
|
||||
"shell.execute_reply": "2024-09-17T01:49:44.374342Z",
|
||||
"shell.execute_reply.started": "2024-09-17T01:49:44.352780Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"filename = 'data/镇海.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" dict2 = {}\n",
|
||||
" #if dict1['sex'] =='男':\n",
|
||||
" # sex = 1\n",
|
||||
" \n",
|
||||
" dict2 = {'id':k,'name':v['name'],'gender':v['sex'],'birth':v['birth'],'unit':v['unit']}\n",
|
||||
" list1.append(dict2)\n",
|
||||
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
|
||||
"\n",
|
||||
"# 将 json 数据写入文件\n",
|
||||
"with open(\"data/data_镇海.json\", \"w\",encoding = 'utf-8') as file:\n",
|
||||
" file.write(json_data) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b6dd08b0-f58c-4dc1-86a9-e7b2b84478c3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 获取人员测试成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"id": "5d864909-d10f-461d-8e6e-dc5c43613576",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-20T08:48:09.078723Z",
|
||||
"iopub.status.busy": "2024-09-20T08:48:09.077996Z",
|
||||
"iopub.status.idle": "2024-09-20T08:48:09.151435Z",
|
||||
"shell.execute_reply": "2024-09-20T08:48:09.150864Z",
|
||||
"shell.execute_reply.started": "2024-09-20T08:48:09.078657Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"934\n",
|
||||
"934\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\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",
|
||||
"re_ta = {}\n",
|
||||
"dict1 = {}\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/镇海.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"filename = 'data/places_result_20240920.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",
|
||||
"#print(list1)\n",
|
||||
"for result in list1:\n",
|
||||
" user = str(result[2])\n",
|
||||
" if user in dict1.keys(): \n",
|
||||
" m_item = str(result[3]) \n",
|
||||
" re_ta.setdefault(user,{}) \n",
|
||||
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||||
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
||||
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
||||
" #re_ta[user]['sub_unit'] = dict1[user]['sub_unit']\n",
|
||||
" item_name = item[m_item]['name']\n",
|
||||
" re_ta[user].setdefault(item_name,{}) \n",
|
||||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||
"print(len(re_ta))\n",
|
||||
"filename = 'data/result_镇海.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a08c6b65-a390-451b-b1a5-fc474db40035",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导出测试人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"id": "bc79f0d2-62a2-40c8-bd74-9c7ff17bec8e",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-20T08:48:32.839532Z",
|
||||
"iopub.status.busy": "2024-09-20T08:48:32.838772Z",
|
||||
"iopub.status.idle": "2024-09-20T08:48:33.052265Z",
|
||||
"shell.execute_reply": "2024-09-20T08:48:33.051700Z",
|
||||
"shell.execute_reply.started": "2024-09-20T08:48:32.839461Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"\n",
|
||||
"filename = 'data/result_镇海.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/镇海.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
" \n",
|
||||
"list1 = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list2 = []\n",
|
||||
" list2.append(str(k).rjust(5,'0'))\n",
|
||||
" list2.append(v['name']) \n",
|
||||
" list2.append(dict2[k]['sex'])\n",
|
||||
" list2.append(dict2[k]['unit']) \n",
|
||||
" for item in items:\n",
|
||||
" if item in v.keys():\n",
|
||||
" list2.append(v[item]['成绩']) \n",
|
||||
" elif item =='name':\n",
|
||||
" list2.append(v[item])\n",
|
||||
" else:\n",
|
||||
" list2.append('') \n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/镇海体测情况(截至20240920).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
"for row in list1:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0c2dfa71-8680-4ec6-938d-d37eeba4d4f9",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计未体测人员明细表"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"id": "cf22739a-5cf3-47fd-b87a-158a2e2d5a95",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-20T08:49:06.241970Z",
|
||||
"iopub.status.busy": "2024-09-20T08:49:06.241223Z",
|
||||
"iopub.status.idle": "2024-09-20T08:49:06.291731Z",
|
||||
"shell.execute_reply": "2024-09-20T08:49:06.291195Z",
|
||||
"shell.execute_reply.started": "2024-09-20T08:49:06.241901Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"filename = 'data/result_镇海.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/镇海1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"\n",
|
||||
"i = 1\n",
|
||||
"for k, v in dict2.items(): \n",
|
||||
" if k not in dict1.keys():\n",
|
||||
" list2 = [i,k,v['name'],v['unit']]\n",
|
||||
" i+=1\n",
|
||||
" list1.append(list2)\n",
|
||||
"#print(list1)\n",
|
||||
"filename = f'data/镇海未测试人员名单.xlsx'\n",
|
||||
"title = ['序号','员工编号','姓名','部门']\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
"for row in list1:\n",
|
||||
" sheet.append(row) \n",
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "286a65eb-995f-4183-a4e5-6d907ba21151",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 清理重复人员"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"id": "f4dade65-f760-4220-8a65-39843688a60a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-09-20T08:48:41.723955Z",
|
||||
"iopub.status.busy": "2024-09-20T08:48:41.723229Z",
|
||||
"iopub.status.idle": "2024-09-20T08:48:41.926161Z",
|
||||
"shell.execute_reply": "2024-09-20T08:48:41.925529Z",
|
||||
"shell.execute_reply.started": "2024-09-20T08:48:41.723892Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1354\n",
|
||||
"1298\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"filename = 'data/镇海.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"print(len(dict1))\n",
|
||||
"dict2 = {}\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" dict2.setdefault(k,{})\n",
|
||||
" dict2[k]['name'] = v['name']\n",
|
||||
" dict2[k]['phone'] = v['phone']\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" i = 0\n",
|
||||
" for k1, v1 in dict1.items():\n",
|
||||
" if v['name']== v1['name'] and v['phone'] == v1['phone'] and k1 != k:\n",
|
||||
" list1.append(max(int(k),int(k1)))\n",
|
||||
"for item in set(list1):\n",
|
||||
" del dict1[str(item)]\n",
|
||||
"print(len(dict1))\n",
|
||||
"filename = 'data/镇海1.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False) \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ef930e32-9413-4fb0-b9e4-ba548d89ec60",
|
||||
"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.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in new issue
Block a user