20231127
This commit is contained in:
1 parent
3b4acc857c
commit
2d6db59b1c
4 files changed
+350
-117
No files matched your search
+102
-70
@@ -23,8 +23,8 @@
|
|||||||
"mydb = myclient[\"baogao\"]\n",
|
"mydb = myclient[\"baogao\"]\n",
|
||||||
"mycol = mydb[\"place\"]\n",
|
"mycol = mydb[\"place\"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"id = 624770\n",
|
"id = 698465\n",
|
||||||
"name = \"淄博世纪花园\"\n",
|
"name = \"淄博积家村\"\n",
|
||||||
"myquery = { \"id\": id }\n",
|
"myquery = { \"id\": id }\n",
|
||||||
"num = mycol.count_documents(myquery)\n",
|
"num = mycol.count_documents(myquery)\n",
|
||||||
"if num>0:\n",
|
"if num>0:\n",
|
||||||
@@ -63,9 +63,9 @@
|
|||||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||||
"mydb = myclient[\"baogao\"]\n",
|
"mydb = myclient[\"baogao\"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"place_id = 624770\n",
|
"place_id = 698465\n",
|
||||||
"place_code = '05'\n",
|
"place_code = '06'\n",
|
||||||
"dw_name = '淄博世纪花园'\n",
|
"dw_name = '淄博积家村'\n",
|
||||||
"fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n",
|
"fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n",
|
||||||
"fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n",
|
"fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
"while i < len(fls):\n",
|
"while i < len(fls):\n",
|
||||||
" code = random.sample(code_list,4) #随机取4位数\n",
|
" code = random.sample(code_list,4) #随机取4位数\n",
|
||||||
" code_num = ''.join(code) \n",
|
" code_num = ''.join(code) \n",
|
||||||
" if code_num not in list1:\n",
|
" if place_code+code_num not in list1:\n",
|
||||||
" list1.append(place_code+code_num)\n",
|
" list1.append(place_code+code_num)\n",
|
||||||
" i +=1\n",
|
" i +=1\n",
|
||||||
"i = 0\n",
|
"i = 0\n",
|
||||||
@@ -97,12 +97,12 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "markdown",
|
||||||
"execution_count": null,
|
"id": "ad9e943a-bb3a-4d58-93ef-cc442a80effa",
|
||||||
"id": "767cdc9b-310e-4922-8b7d-3581a328cf45",
|
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"source": [
|
||||||
"source": []
|
"## 批量发送短信(测试)"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@@ -113,6 +113,11 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
"from tencentcloud.common import credential\n",
|
||||||
|
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||||
|
"from tencentcloud.sms.v20210111 import sms_client, models\n",
|
||||||
|
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
|
||||||
|
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import pymongo\n",
|
"import pymongo\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -120,20 +125,50 @@
|
|||||||
"mydb = myclient[\"baogao\"]\n",
|
"mydb = myclient[\"baogao\"]\n",
|
||||||
"mycol = mydb[\"pdf\"]\n",
|
"mycol = mydb[\"pdf\"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/世纪花园人员信息.json'\n",
|
"filename = 'data/积家村报告明细.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"dict2 = {}\n",
|
"dict2 = {}\n",
|
||||||
"place_id = 624770\n",
|
"place_id = 698465\n",
|
||||||
"myquery = { \"place_id\": place_id }\n",
|
"myquery = { \"place_id\": place_id }\n",
|
||||||
"for x in mycol.find(myquery,{ \"_id\": 0, \"place_id\": 0}):\n",
|
"for x in mycol.find(myquery,{ \"_id\": 0, \"place_id\": 0}):\n",
|
||||||
" code = int(x['fn'].split('-')[0])\n",
|
" code = int(x['fn'].split('-')[0])\n",
|
||||||
" if str(code) in dict1.keys():\n",
|
" if str(code) in dict1.keys() and 'phone' in dict1[str(code)].keys():\n",
|
||||||
" dict2[code] = {'name':str(dict1[str(code)]['name']),'phone':str(dict1[str(code)]['phone']),'code':x['code']}\n",
|
" dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code']}\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" print(code,'no phone')\n",
|
" print(code,'no phone')\n",
|
||||||
"for k,v in dict2.items():\n",
|
"#print(dict2)\n",
|
||||||
" print(k,v['name'],v['phone'],v['code'])"
|
"for k, v in dict2.items():\n",
|
||||||
|
" phone = '+86'+v['phone']\n",
|
||||||
|
" yzm = v['code']\n",
|
||||||
|
" try: \n",
|
||||||
|
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
||||||
|
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
||||||
|
" cred = credential.Credential(secretId, secretKey) \n",
|
||||||
|
" httpProfile = HttpProfile()\n",
|
||||||
|
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
||||||
|
" httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)\n",
|
||||||
|
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
||||||
|
" clientProfile = ClientProfile()\n",
|
||||||
|
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
||||||
|
" clientProfile.language = \"en-US\"\n",
|
||||||
|
" clientProfile.httpProfile = httpProfile\n",
|
||||||
|
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
||||||
|
" req = models.SendSmsRequest()\n",
|
||||||
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
||||||
|
" req.SignName = \"坤铭教育\"\n",
|
||||||
|
" req.TemplateId = \"1875765\" \n",
|
||||||
|
" req.TemplateParamSet = [\"淄博积家村体测者\",yzm]\n",
|
||||||
|
" req.PhoneNumberSet = [phone]\n",
|
||||||
|
" req.SessionContext = \"\"\n",
|
||||||
|
" req.ExtendCode = \"\"\n",
|
||||||
|
" 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",
|
||||||
|
" except TencentCloudSDKException as err:\n",
|
||||||
|
" print(v['phone'],err)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -169,7 +204,7 @@
|
|||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"dict2 = {}\n",
|
"dict2 = {}\n",
|
||||||
"place_id = 624770\n",
|
"place_id = 698465\n",
|
||||||
"myquery = { \"place_id\": place_id }\n",
|
"myquery = { \"place_id\": place_id }\n",
|
||||||
"for x in mycol.find(myquery,{ \"_id\": 0, \"place_id\": 0}):\n",
|
"for x in mycol.find(myquery,{ \"_id\": 0, \"place_id\": 0}):\n",
|
||||||
" code = int(x['fn'].split('-')[0])\n",
|
" code = int(x['fn'].split('-')[0])\n",
|
||||||
@@ -200,7 +235,7 @@
|
|||||||
" req.SmsSdkAppId = \"1400140089\"\n",
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
||||||
" req.SignName = \"坤铭教育\"\n",
|
" req.SignName = \"坤铭教育\"\n",
|
||||||
" req.TemplateId = \"1875765\" \n",
|
" req.TemplateId = \"1875765\" \n",
|
||||||
" req.TemplateParamSet = [\"淄博世纪花园体测者\",yzm]\n",
|
" req.TemplateParamSet = [\"淄博积家村体测者\",yzm]\n",
|
||||||
" req.PhoneNumberSet = [phone]\n",
|
" req.PhoneNumberSet = [phone]\n",
|
||||||
" req.SessionContext = \"\"\n",
|
" req.SessionContext = \"\"\n",
|
||||||
" req.ExtendCode = \"\"\n",
|
" req.ExtendCode = \"\"\n",
|
||||||
@@ -234,12 +269,27 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 86,
|
||||||
"id": "25a269c3-758f-4e79-ae6d-a6e6f161d64b",
|
"id": "25a269c3-758f-4e79-ae6d-a6e6f161d64b",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-27T03:02:47.586339Z",
|
||||||
|
"iopub.status.busy": "2023-11-27T03:02:47.585869Z",
|
||||||
|
"iopub.status.idle": "2023-11-27T03:02:47.873412Z",
|
||||||
|
"shell.execute_reply": "2023-11-27T03:02:47.872245Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-27T03:02:47.586301Z"
|
||||||
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"+8618264313303 send success\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"from tencentcloud.common import credential\n",
|
"from tencentcloud.common import credential\n",
|
||||||
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||||
@@ -249,56 +299,38 @@
|
|||||||
"import json\n",
|
"import json\n",
|
||||||
"import pymongo\n",
|
"import pymongo\n",
|
||||||
"\n",
|
"\n",
|
||||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
|
||||||
"mydb = myclient[\"baogao\"]\n",
|
|
||||||
"mycol = mydb[\"pdf\"]\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/世纪花园人员信息.json'\n",
|
|
||||||
"with open(filename,'r') as fl:\n",
|
|
||||||
" dict1 = json.load(fl) \n",
|
|
||||||
"dict2 = {}\n",
|
|
||||||
"place_id = 624770\n",
|
|
||||||
"myquery = { \"place_id\": place_id,\"code\":\"053618\" }\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():\n",
|
|
||||||
" dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code']}\n",
|
|
||||||
" else:\n",
|
|
||||||
" print('no phone')\n",
|
|
||||||
"#print(dict2)\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}\n",
|
"phone = '+86'+'18264313303'\n",
|
||||||
"for k, v in dict2.items():\n",
|
"yzm = '066357'\n",
|
||||||
" phone = '+86'+v['phone']\n",
|
"try: \n",
|
||||||
" yzm = v['code']\n",
|
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
||||||
" try: \n",
|
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
||||||
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
" cred = credential.Credential(secretId, secretKey) \n",
|
||||||
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
" httpProfile = HttpProfile()\n",
|
||||||
" cred = credential.Credential(secretId, secretKey) \n",
|
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
||||||
" httpProfile = HttpProfile()\n",
|
" httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)\n",
|
||||||
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
||||||
" httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)\n",
|
" clientProfile = ClientProfile()\n",
|
||||||
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
||||||
" clientProfile = ClientProfile()\n",
|
" clientProfile.language = \"en-US\"\n",
|
||||||
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
" clientProfile.httpProfile = httpProfile\n",
|
||||||
" clientProfile.language = \"en-US\"\n",
|
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
||||||
" clientProfile.httpProfile = httpProfile\n",
|
" req = models.SendSmsRequest()\n",
|
||||||
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
||||||
" req = models.SendSmsRequest()\n",
|
" req.SignName = \"坤铭教育\"\n",
|
||||||
" req.SmsSdkAppId = \"1400140089\"\n",
|
" req.TemplateId = \"1875765\" \n",
|
||||||
" req.SignName = \"坤铭教育\"\n",
|
" req.TemplateParamSet = [\"淄博积家村体测者\",yzm]\n",
|
||||||
" req.TemplateId = \"1875765\" \n",
|
" req.PhoneNumberSet = [phone]\n",
|
||||||
" req.TemplateParamSet = [\"淄博世纪花园体测者\",yzm]\n",
|
" req.SessionContext = \"\"\n",
|
||||||
" req.PhoneNumberSet = [phone]\n",
|
" req.ExtendCode = \"\"\n",
|
||||||
" req.SessionContext = \"\"\n",
|
" req.SenderId = \"\"\n",
|
||||||
" req.ExtendCode = \"\"\n",
|
" resp = client.SendSms(req)\n",
|
||||||
" req.SenderId = \"\"\n",
|
" dict3 = json.loads(resp.to_json_string(indent=2))\n",
|
||||||
" resp = client.SendSms(req)\n",
|
|
||||||
" dict3 = json.loads(resp.to_json_string(indent=2))\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
" print(v['phone'],dict3['SendStatusSet'][0][\"Message\"])\n",
|
" print(phone,dict3['SendStatusSet'][0][\"Message\"])\n",
|
||||||
" except TencentCloudSDKException as err:\n",
|
"except TencentCloudSDKException as err:\n",
|
||||||
" print(v['phone'],err)"
|
" print(v['phone'],err)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -384,10 +416,10 @@
|
|||||||
" # 偏移量 注:目前固定设置为0\n",
|
" # 偏移量 注:目前固定设置为0\n",
|
||||||
" req.Offset = 0\n",
|
" req.Offset = 0\n",
|
||||||
" # 开始时间,yyyymmddhh 需要拉取的起始时间,精确到小时\n",
|
" # 开始时间,yyyymmddhh 需要拉取的起始时间,精确到小时\n",
|
||||||
" req.BeginTime = \"2023111000\"\n",
|
" req.BeginTime = \"2023112700\"\n",
|
||||||
" # 结束时间,yyyymmddhh 需要拉取的截止时间,精确到小时\n",
|
" # 结束时间,yyyymmddhh 需要拉取的截止时间,精确到小时\n",
|
||||||
" # 注:EndTime 必须大于 BeginTime\n",
|
" # 注:EndTime 必须大于 BeginTime\n",
|
||||||
" req.EndTime = \"2023111023\"\n",
|
" req.EndTime = \"2023112723\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
" # 通过client对象调用SendStatusStatistics方法发起请求。注意请求方法名与请求对象是对应的。\n",
|
" # 通过client对象调用SendStatusStatistics方法发起请求。注意请求方法名与请求对象是对应的。\n",
|
||||||
|
|||||||
+61
-15
@@ -280,12 +280,28 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 51,
|
||||||
"id": "3e614f4a-a623-48e2-97f8-b31f62c9a983",
|
"id": "3e614f4a-a623-48e2-97f8-b31f62c9a983",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-26T12:33:04.366772Z",
|
||||||
|
"iopub.status.busy": "2023-11-26T12:33:04.366311Z",
|
||||||
|
"iopub.status.idle": "2023-11-26T12:33:04.395519Z",
|
||||||
|
"shell.execute_reply": "2023-11-26T12:33:04.394381Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-26T12:33:04.366735Z"
|
||||||
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"16\n",
|
||||||
|
"16\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import datetime\n",
|
"import datetime\n",
|
||||||
@@ -315,11 +331,11 @@
|
|||||||
"re_ta = {}\n",
|
"re_ta = {}\n",
|
||||||
"dict1 = {}\n",
|
"dict1 = {}\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"filename = 'data/北海炼化2023年.json'\n",
|
"filename = 'data/北京党校.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/places_result_20231119.csv'\n",
|
"filename = 'data/places_result_20231126.csv'\n",
|
||||||
"with open(filename,'r',newline='') as csv_file:\n",
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
" header = next(fl) \n",
|
" header = next(fl) \n",
|
||||||
@@ -359,7 +375,7 @@
|
|||||||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||||||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||||
"print(len(re_ta))\n",
|
"print(len(re_ta))\n",
|
||||||
"filename = 'data/result_北海炼化2023.json'\n",
|
"filename = 'data/result_北京党校20231126.json'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||||
@@ -376,12 +392,27 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 52,
|
||||||
"id": "141b30dc-5975-4dcb-9bc3-9b20d26a0917",
|
"id": "141b30dc-5975-4dcb-9bc3-9b20d26a0917",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-26T12:33:25.037310Z",
|
||||||
|
"iopub.status.busy": "2023-11-26T12:33:25.036852Z",
|
||||||
|
"iopub.status.idle": "2023-11-26T12:33:25.068487Z",
|
||||||
|
"shell.execute_reply": "2023-11-26T12:33:25.068065Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-26T12:33:25.037274Z"
|
||||||
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok!\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import time\n",
|
"import time\n",
|
||||||
@@ -479,7 +510,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"#list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','height','weight']\n",
|
"#list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','height','weight']\n",
|
||||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||||
"filename = 'data/result_北海炼化2023.json'\n",
|
"filename = 'data/result_北京党校20231126.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict2 = json.load(fl) \n",
|
" dict2 = json.load(fl) \n",
|
||||||
"for k, v in dict2.items():\n",
|
"for k, v in dict2.items():\n",
|
||||||
@@ -500,7 +531,7 @@
|
|||||||
" dict2[k][item_en]['score'] = cal_score(data1)\n",
|
" dict2[k][item_en]['score'] = cal_score(data1)\n",
|
||||||
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = f'data/result_北海炼化2023.json'\n",
|
"filename = f'data/result_北京党校20231126.json'\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||||
"print('ok!') "
|
"print('ok!') "
|
||||||
@@ -557,12 +588,27 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 54,
|
||||||
"id": "b123ee6b-85d2-4660-b226-321832a6b796",
|
"id": "b123ee6b-85d2-4660-b226-321832a6b796",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-26T12:39:01.504677Z",
|
||||||
|
"iopub.status.busy": "2023-11-26T12:39:01.504412Z",
|
||||||
|
"iopub.status.idle": "2023-11-26T12:39:07.037937Z",
|
||||||
|
"shell.execute_reply": "2023-11-26T12:39:07.036619Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-26T12:39:01.504657Z"
|
||||||
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"17\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import requests\n",
|
"import requests\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -572,11 +618,11 @@
|
|||||||
"headers = {\n",
|
"headers = {\n",
|
||||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||||
" }\n",
|
" }\n",
|
||||||
"filename = 'data/result_天津231017.json'\n",
|
"filename = 'data/result_北京党校20231126.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl)\n",
|
" dict1 = json.load(fl)\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"fiie_path ='./134/'\n",
|
"fiie_path ='./中央和国家机关党校1126/'\n",
|
||||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||||
"i=1\n",
|
"i=1\n",
|
||||||
"list2 = []\n",
|
"list2 = []\n",
|
||||||
@@ -584,9 +630,9 @@
|
|||||||
" list1 = []\n",
|
" list1 = []\n",
|
||||||
" mydata = {}\n",
|
" mydata = {}\n",
|
||||||
" \n",
|
" \n",
|
||||||
" id = str(k).rjust(8,\"0\")\n",
|
" id = str(k).rjust(4,\"0\")\n",
|
||||||
" mydata['path'] = fiie_path+id+'-'+ v['name']+'.pdf'\n",
|
" mydata['path'] = fiie_path+id+'-'+ v['name']+'.pdf'\n",
|
||||||
" mydata['title'] = '中石化(天津)石油化工\\n有限公司'\n",
|
" mydata['title'] = '中央和国家机关党校'\n",
|
||||||
" mydata['subtitle'] = v['unit']\n",
|
" mydata['subtitle'] = v['unit']\n",
|
||||||
" mydata['id'] = id\n",
|
" mydata['id'] = id\n",
|
||||||
" mydata['name'] = v['name']\n",
|
" mydata['name'] = v['name']\n",
|
||||||
|
|||||||
+28
-13
@@ -10,18 +10,33 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 8,
|
||||||
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
|
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-26T12:30:54.402556Z",
|
||||||
|
"iopub.status.busy": "2023-11-26T12:30:54.402097Z",
|
||||||
|
"iopub.status.idle": "2023-11-26T12:30:54.454920Z",
|
||||||
|
"shell.execute_reply": "2023-11-26T12:30:54.453841Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-26T12:30:54.402519Z"
|
||||||
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"wb = openpyxl.load_workbook('data/报名登记表142人.xlsx')\n",
|
"wb = openpyxl.load_workbook('data/报名登记表164人.xlsx')\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"# sheets = wb.sheetnames\n",
|
"# sheets = wb.sheetnames\n",
|
||||||
"person = {}\n",
|
"person = {}\n",
|
||||||
@@ -89,15 +104,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 7,
|
"execution_count": 9,
|
||||||
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2023-10-18T02:17:23.733390Z",
|
"iopub.execute_input": "2023-11-26T12:31:39.094899Z",
|
||||||
"iopub.status.busy": "2023-10-18T02:17:23.733131Z",
|
"iopub.status.busy": "2023-11-26T12:31:39.094370Z",
|
||||||
"iopub.status.idle": "2023-10-18T02:17:23.758353Z",
|
"iopub.status.idle": "2023-11-26T12:31:39.114981Z",
|
||||||
"shell.execute_reply": "2023-10-18T02:17:23.757550Z",
|
"shell.execute_reply": "2023-11-26T12:31:39.114071Z",
|
||||||
"shell.execute_reply.started": "2023-10-18T02:17:23.733366Z"
|
"shell.execute_reply.started": "2023-11-26T12:31:39.094860Z"
|
||||||
},
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
@@ -106,8 +121,8 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"141\n",
|
"16\n",
|
||||||
"141\n"
|
"16\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -130,7 +145,7 @@
|
|||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/places_result_20231018.csv'\n",
|
"filename = 'data/places_result_20231126.csv'\n",
|
||||||
"with open(filename,'r',newline='') as csv_file:\n",
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
" header = next(fl) \n",
|
" header = next(fl) \n",
|
||||||
@@ -151,7 +166,7 @@
|
|||||||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||||||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||||
"print(len(re_ta))\n",
|
"print(len(re_ta))\n",
|
||||||
"filename = 'data/result_北京党校.json'\n",
|
"filename = 'data/result_北京党校20231126.json'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||||
|
|||||||
+159
-19
@@ -555,28 +555,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 38,
|
"execution_count": null,
|
||||||
"id": "fbe793e4-04cf-4e7d-8fb8-1776ed474ab9",
|
"id": "fbe793e4-04cf-4e7d-8fb8-1776ed474ab9",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-11-10T04:50:35.767483Z",
|
|
||||||
"iopub.status.busy": "2023-11-10T04:50:35.767191Z",
|
|
||||||
"iopub.status.idle": "2023-11-10T04:50:35.978054Z",
|
|
||||||
"shell.execute_reply": "2023-11-10T04:50:35.977514Z",
|
|
||||||
"shell.execute_reply.started": "2023-11-10T04:50:35.767458Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"('ptv_0533_jj','段玉华','953','{\"Gender\":\"f\",\"Age\":\"O\",\"q1O\":3,\"q2O\":3,\"q3O\":4,\"q4O\":1,\"q5O\":4,\"q6O\":4,\"q7O\":4,\"q8O\":4,\"q9O\":5,\"q10O\":1,\"q11O\":3,\"q12O\":4,\"q13O\":4,\"q14O\":4,\"q15O\":4,\"q16O\":5,\"q17O\":5,\"q18O\":4,\"q19O\":3,\"q20O\":4,\"q21O\":3,\"q22O\":4,\"q23O\":5,\"q24O\":5,\"q25O\":4,\"q26O\":4,\"q27O\":3,\"q28O\":3,\"q29O\":3,\"q30O\":3,\"q1\":3,\"q3\":2,\"q4\":1,\"q5\":3,\"q6\":3,\"q8\":3,\"q10\":3,\"q13\":4,\"q14\":3,\"q15\":3,\"q16\":2,\"q17\":2,\"q18\":2,\"q19\":2,\"q20\":1,\"q22\":2,\"q23\":3,\"q25\":2,\"q26\":2,\"q27\":2,\"q28\":2,\"q29\":2,\"q30\":3,\"q31\":2,\"q32\":2,\"q33\":2,\"q34\":2,\"q35\":3,\"q36\":2,\"q37\":1,\"q38\":2,\"q39\":3,\"q40\":2,\"q41\":1,\"q42\":1,\"q43\":1,\"q44\":3,\"q45\":3,\"q46\":3,\"q47\":3,\"q48\":3,\"q49\":2,\"q50\":3,\"q51\":1,\"q52\":3,\"q53\":1,\"q54\":3,\"q55\":1,\"q56\":1,\"q57\":1,\"q58\":1,\"q59\":1,\"q60\":1,\"qv1\":1,\"qv2\":2,\"qv3\":1,\"qv4\":1,\"qv5\":2,\"qv6\":2,\"qv7\":1,\"qv8\":1,\"qv9\":2,\"qv10\":2,\"qv11\":2,\"qv12\":1,\"qv13\":2,\"qv14\":2,\"qv15\":1,\"qv16\":1,\"qv17\":2,\"qv18\":1,\"qv19\":2,\"qv20\":2,\"qv21\":2,\"qv22\":2,\"qv23\":2,\"qv24\":1,\"qv25\":1,\"qv26\":2}','2023-11-10 12:00:00'),('ptv_0533_jj','孙俊英','329','{\"Gender\":\"f\",\"Age\":\"O\",\"q1O\":1,\"q2O\":1,\"q3O\":1,\"q4O\":1,\"q5O\":5,\"q6O\":5,\"q7O\":5,\"q8O\":5,\"q9O\":5,\"q10O\":1,\"q11O\":5,\"q12O\":5,\"q13O\":5,\"q14O\":5,\"q15O\":5,\"q16O\":5,\"q17O\":5,\"q18O\":1,\"q19O\":4,\"q20O\":5,\"q21O\":5,\"q22O\":5,\"q23O\":5,\"q24O\":5,\"q25O\":5,\"q26O\":4,\"q27O\":4,\"q28O\":2,\"q29O\":4,\"q30O\":5,\"q1\":5,\"q3\":1,\"q4\":3,\"q5\":1,\"q6\":4,\"q8\":4,\"q10\":3,\"q13\":1,\"q14\":3,\"q15\":1,\"q16\":1,\"q17\":3,\"q18\":1,\"q19\":1,\"q20\":1,\"q22\":1,\"q23\":1,\"q25\":1,\"q26\":1,\"q27\":1,\"q28\":1,\"q29\":1,\"q30\":1,\"q31\":1,\"q32\":1,\"q33\":1,\"q34\":1,\"q35\":1,\"q36\":1,\"q37\":1,\"q38\":1,\"q39\":1,\"q40\":1,\"q41\":1,\"q42\":1,\"q43\":1,\"q44\":3,\"q45\":3,\"q46\":1,\"q47\":1,\"q48\":3,\"q49\":1,\"q50\":2,\"q51\":3,\"q52\":1,\"q53\":1,\"q54\":1,\"q55\":3,\"q56\":1,\"q57\":1,\"q58\":1,\"q59\":1,\"q60\":1,\"qv1\":2,\"qv2\":2,\"qv3\":2,\"qv4\":2,\"qv5\":2,\"qv6\":2,\"qv7\":1,\"qv8\":2,\"qv9\":2,\"qv10\":2,\"qv11\":2,\"qv12\":2,\"qv13\":2,\"qv14\":2,\"qv15\":2,\"qv16\":2,\"qv17\":2,\"qv18\":1,\"qv19\":2,\"qv20\":2,\"qv21\":2,\"qv22\":2,\"qv23\":2,\"qv24\":2,\"qv25\":2,\"qv26\":2}','2023-11-10 12:00:00'),('ptv_0533_jj','赵兰芬','1125','{\"Gender\":\"f\",\"Age\":\"O\",\"q1O\":4,\"q2O\":4,\"q3O\":2,\"q4O\":1,\"q5O\":4,\"q6O\":4,\"q7O\":4,\"q8O\":3,\"q9O\":5,\"q10O\":2,\"q11O\":4,\"q12O\":5,\"q13O\":5,\"q14O\":5,\"q15O\":5,\"q16O\":4,\"q17O\":4,\"q18O\":3,\"q19O\":4,\"q20O\":4,\"q21O\":4,\"q22O\":4,\"q23O\":4,\"q24O\":4,\"q25O\":5,\"q26O\":5,\"q27O\":4,\"q28O\":2,\"q29O\":4,\"q30O\":3,\"q1\":3,\"q3\":2,\"q4\":3,\"q5\":2,\"q6\":4,\"q8\":4,\"q10\":3,\"q13\":1,\"q14\":3,\"q15\":2,\"q16\":3,\"q17\":1,\"q18\":1,\"q19\":1,\"q20\":1,\"q22\":4,\"q23\":1,\"q25\":1,\"q26\":3,\"q27\":4,\"q28\":3,\"q29\":3,\"q30\":4,\"q31\":2,\"q32\":4,\"q33\":4,\"q34\":3,\"q35\":4,\"q36\":3,\"q37\":2,\"q38\":4,\"q39\":3,\"q40\":3,\"q41\":1,\"q42\":1,\"q43\":1,\"q44\":4,\"q45\":3,\"q46\":4,\"q47\":4,\"q48\":1,\"q49\":3,\"q50\":1,\"q51\":1,\"q52\":3,\"q53\":3,\"q54\":1,\"q55\":1,\"q56\":1,\"q57\":1,\"q58\":1,\"q59\":1,\"q60\":2,\"qv1\":1,\"qv2\":2,\"qv3\":2,\"qv4\":1,\"qv5\":2,\"qv6\":2,\"qv7\":1,\"qv8\":1,\"qv9\":1,\"qv10\":2,\"qv11\":1,\"qv12\":2,\"qv13\":1,\"qv14\":2,\"qv15\":1,\"qv16\":1,\"qv17\":2,\"qv18\":1,\"qv19\":2,\"qv20\":2,\"qv21\":1,\"qv22\":1,\"qv23\":2,\"qv24\":1,\"qv25\":2,\"qv26\":1}','2023-11-10 12:00:00'),('ptv_0533_jj','王翠华','1608','{\"Gender\":\"f\",\"Age\":\"O\",\"q1O\":1,\"q2O\":1,\"q3O\":1,\"q4O\":1,\"q5O\":5,\"q6O\":5,\"q7O\":5,\"q8O\":5,\"q9O\":5,\"q10O\":1,\"q11O\":5,\"q12O\":5,\"q13O\":5,\"q14O\":5,\"q15O\":5,\"q16O\":5,\"q17O\":5,\"q18O\":1,\"q19O\":3,\"q20O\":5,\"q21O\":5,\"q22O\":5,\"q23O\":5,\"q24O\":5,\"q25O\":5,\"q26O\":4,\"q27O\":4,\"q28O\":2,\"q29O\":4,\"q30O\":5,\"q1\":5,\"q3\":1,\"q4\":3,\"q5\":1,\"q6\":4,\"q8\":4,\"q10\":1,\"q13\":1,\"q14\":1,\"q15\":1,\"q16\":1,\"q17\":3,\"q18\":1,\"q19\":1,\"q20\":1,\"q22\":1,\"q23\":1,\"q25\":1,\"q26\":1,\"q27\":1,\"q28\":1,\"q29\":1,\"q30\":1,\"q31\":1,\"q32\":1,\"q33\":1,\"q34\":1,\"q35\":1,\"q36\":1,\"q37\":1,\"q38\":1,\"q39\":1,\"q40\":1,\"q41\":1,\"q42\":1,\"q43\":1,\"q44\":3,\"q45\":3,\"q46\":1,\"q47\":1,\"q48\":3,\"q49\":1,\"q50\":2,\"q51\":3,\"q52\":1,\"q53\":1,\"q54\":3,\"q55\":5,\"q56\":1,\"q57\":1,\"q58\":1,\"q59\":1,\"q60\":1,\"qv1\":2,\"qv2\":2,\"qv3\":2,\"qv4\":2,\"qv5\":2,\"qv6\":2,\"qv7\":1,\"qv8\":2,\"qv9\":2,\"qv10\":2,\"qv11\":2,\"qv12\":2,\"qv13\":2,\"qv14\":2,\"qv15\":2,\"qv16\":2,\"qv17\":2,\"qv18\":1,\"qv19\":2,\"qv20\":2,\"qv21\":2,\"qv22\":2,\"qv23\":2,\"qv24\":2,\"qv25\":2,\"qv26\":2}','2023-11-10 12:00:00'),('ptv_0533_jj','胡桂香','547','{\"Gender\":\"f\",\"Age\":\"O\",\"q1O\":3,\"q2O\":1,\"q3O\":1,\"q4O\":1,\"q5O\":5,\"q6O\":5,\"q7O\":5,\"Line truncated
|
|
||||||
"{'encoding': 'utf-8', 'confidence': 0.99, 'language': ''}\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -640,10 +624,166 @@
|
|||||||
"print (chardet.detect(str.encode(s)))"
|
"print (chardet.detect(str.encode(s)))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "58417d26-1d6c-4583-ac35-3469fa6b85fd",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 读取读卡系统人员信息"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "9a634c3b-6954-4eff-bc1c-3f5e229bc458",
|
"id": "08e9afb8-a68b-4199-9020-67bc7cd1bd0a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b38517cd-268c-4e80-a4f1-002bf45d81f0",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/积家data(1).json'\n",
|
||||||
|
"with open(filename,'r',encoding='utf8') as fl:\n",
|
||||||
|
" list1 = json.load(fl)\n",
|
||||||
|
"i = 1\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" if item['phone'] !='':\n",
|
||||||
|
" print(item['name'],item['phone'])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "4e201e43-3cb1-4511-bf1b-721fc18275db",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 核对报告人员信息"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 23,
|
||||||
|
"id": "f370a41c-4f61-4311-8aa9-95946dca42c7",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-26T11:36:23.485942Z",
|
||||||
|
"iopub.status.busy": "2023-11-26T11:36:23.485461Z",
|
||||||
|
"iopub.status.idle": "2023-11-26T11:36:23.534771Z",
|
||||||
|
"shell.execute_reply": "2023-11-26T11:36:23.533403Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-26T11:36:23.485898Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"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",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/积家data(1).json'\n",
|
||||||
|
"with open(filename,'r',encoding='utf8') as fl:\n",
|
||||||
|
" list1 = json.load(fl)\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" code = str(int(item['id']))\n",
|
||||||
|
" dict2.setdefault(code,{})\n",
|
||||||
|
" dict2[code]= {'name':item['name'],'sex':item['gender'],'birth':item['birth'],'phone':item['phone']}\n",
|
||||||
|
"#print(dict2)\n",
|
||||||
|
"\n",
|
||||||
|
"place_id = 698465\n",
|
||||||
|
"fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n",
|
||||||
|
"fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n",
|
||||||
|
"i = 1\n",
|
||||||
|
"list2 = []\n",
|
||||||
|
"for fn in fls:\n",
|
||||||
|
" list3 = []\n",
|
||||||
|
" fi_name =Path(fn).stem.split('-')[0]\n",
|
||||||
|
" code = str(int(fi_name))\n",
|
||||||
|
" if code in dict2.keys():\n",
|
||||||
|
" list3 = [code,dict2[code]['name'],dict2[code]['sex'],dict2[code]['phone']]\n",
|
||||||
|
" list2.append(list3)\n",
|
||||||
|
"filename = 'data/积家村报告明细.xlsx'\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"\n",
|
||||||
|
"for row in list2:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
"wb.save(filename) "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e92098ad-d57b-461b-9ec5-e26d0801ff8d",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成报告信息"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 24,
|
||||||
|
"id": "f12f5070-005f-42fb-869c-f0b4b18de4ec",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-26T11:49:51.275785Z",
|
||||||
|
"iopub.status.busy": "2023-11-26T11:49:51.275273Z",
|
||||||
|
"iopub.status.idle": "2023-11-26T11:49:51.316526Z",
|
||||||
|
"shell.execute_reply": "2023-11-26T11:49:51.315347Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-26T11:49:51.275718Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\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 = 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",
|
||||||
|
" if sheet.cell(n,4).value is not None:\n",
|
||||||
|
" dict1['phone'] = sheet.cell(n,4).value\n",
|
||||||
|
" \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": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "e80a1efa-9b54-416d-a7e2-fc4ced0adada",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
Reference in new issue
Block a user