46 KiB
46 KiB
In [ ]:
import openpyxl
import json
wb = openpyxl.load_workbook('data/农业银行测试名单.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
person = {}
for n in range(2, sheet.max_row+1):
if sheet.cell(n,1).value is not None:
code = int(sheet.cell(n, 2).value)
person.setdefault(code, {})
dict1 = {}
dict1['name'] = sheet.cell(n, 3).value
if sheet.cell(n, 4).value ==1:
sex = '男'
else:
sex = '女'
dict1['sex'] = sex
birth = str(sheet.cell(n, 5).value).split()[0]
dict1['birth'] = birth
dict1['unit'] = sheet.cell(n, 1).value
if sheet.cell(n,10).value is not None:
dict1['phone'] = sheet.cell(n, 10).value
person[code] = dict1
filename = 'data/北京农行人员名单.json'
with open(filename, 'w') as fl:
json.dump(person, fl, ensure_ascii=False)
print('ok')In [ ]:
import json
import time
import csv
filename = '../item.json'
item = {}
unit = {}
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict1.items():
item[k] = v
re_ta = {}
dict1 = {}
list1 = []
filename = 'data/北京农行人员名单all.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/places_result_20230918.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
#line = re.sub('[\r\n\f ]{1,}', '', line)
list1.append(line)
#print(list1)
for result in list1:
user = str(result[2])
if user in dict1.keys():
m_item = str(result[3])
re_ta.setdefault(user,{})
re_ta[user]['name'] = dict1[user]['name']
re_ta[user]['sex'] = dict1[user]['sex']
re_ta[user]['unit'] = dict1[user]['unit']
item_name = item[m_item]['name']
re_ta[user].setdefault(item_name,{})
score = int(result[4])/item[m_item]['divisor']
re_ta[user][item_name]['成绩'] = f'{score} {item[m_item]["unit"]}'
re_ta[user][item_name]['得分'] = result[5]
print(len(re_ta))
filename = 'data/result_北京农行.json'
with open(filename,'w') as fl:
json.dump(re_ta, fl, ensure_ascii=False)
print(len(re_ta))In [ ]:
import json
import openpyxl
items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']
title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']
filename = 'data/result_北京农行.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/北京农行人员名单all.json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
list1 = []
for k, v in dict1.items():
list2 = []
list2.append(str(k).rjust(5,'0'))
list2.append(v['name'])
list2.append(dict2[k]['sex'])
list2.append(dict2[k]['unit'])
for item in items:
if item in v.keys():
list2.append(v[item]['成绩'])
list2.append(v[item]['得分'])
elif item =='name':
list2.append(v[item])
else:
list2.append('')
list2.append('')
list1.append(list2)
filename = 'data/北京农行体测情况.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
sheet.append(title)
for row in list1:
sheet.append(row)
wb.save(filename)In [ ]:
import os,sys,shutil
import json
import math
import glob
from pathlib import Path
fi_path = 'file/2023-05-23'
old = []
dict2 = {}
filename = 'data/result_北京农行.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
m_name = v['name']
m_depart = v['unit']
dict2[int(k)] = [m_name,m_depart]
fls = glob.glob(f'{fi_path}/*.pdf')
for fn in fls:
old.append(os.path.basename(fn).split('.')[0])
for n in old:
o_name = f'{fi_path}/{n}.pdf'
new_path = Path(fi_path,'new',dict1[n]['unit'])
new_path.mkdir(parents = True, exist_ok = True)
n_name = Path(new_path,f'{str(n).rjust(5,"0")}-{dict2[int(n)][0]}.pdf')
if not os.path.exists(n_name):
shutil.copyfile(o_name,n_name)
print(n_name)
print('ok')In [ ]:
import json
import openpyxl
wb = openpyxl.load_workbook('data/农业银行测试手机号码统计表.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
for n in range(2, sheet.max_row+1):
if sheet.cell(n,5).value is not None:
phone = str(sheet.cell(n, 5).value)
dict1.setdefault(phone,{})
code = str(sheet.cell(n, 2).value)
unit = sheet.cell(n, 1).value
name = sheet.cell(n, 3).value
sex = sheet.cell(n, 4).value
dict1[phone]['code'] = code
dict1[phone]['name'] = name
#dict1[phone]['unit'] = unit
#dict1[phone]['sex'] = sex
filename = 'data/农业银行测试手机号码.json'
with open(filename,'w') as fl:
json.dump(dict1, fl, ensure_ascii=False)
print(len(dict1))
In [ ]:
import random
import json
code_list = []
for i in range(10): # 0~9
code_list.append(str(i))
list1 = []
#print(code_num)
i = 1
while i < 165:
code = random.sample(code_list,6) #随机取6位数
code_num = ''.join(code)
if code_num not in list1:
list1.append(code_num)
i +=1
print(len(list1))
print(list1)
i = 0
filename = 'data/农业银行测试手机号码.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
dict1[k]['yzm'] = list1[i]
i +=1
with open(filename,'w') as fl:
json.dump(dict1, fl, ensure_ascii=False) In [ ]:
filename = 'data/农业银行测试手机号码.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
for k, v in dict1.items():
dict2.setdefault(v['yzm'],{})
dict2[v['yzm']]['code'] = v['code']
dict2[v['yzm']]['name'] = v['name']
print(len(dict2))
filename = 'data/yzm.json'
with open(filename,'w') as fl:
json.dump(dict2, fl, ensure_ascii=False)
In [ ]:
import json
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1875765"
req.TemplateParamSet = ["北京石油分公司体测者","01740518"]
req.PhoneNumberSet = ["+8613793180751"]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
resp = client.SendSms(req)
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print(err)In [ ]:
dict1 = json.loads(resp.to_json_string(indent=2))
print(dict1['SendStatusSet'][0]["Message"])In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
filename = 'data/短信测试手机号码.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
phone = '+86'+str(k)
yzm = v['yzm']
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1808914"
req.TemplateParamSet = [yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
#resp = client.SendSms(req)
dict2 = json.loads(resp.to_json_string(indent=2))
print(v['name'],dict2['SendStatusSet'][0]["Message"])
except TencentCloudSDKException as err:
print(v['name'],err)In [ ]:
import openpyxl
import json
wb = openpyxl.load_workbook('data/北京分行员工体质检测情况表.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
person = {}
for n in range(2, sheet.max_row+1):
if sheet.cell(n,1).value is not None:
code = int(sheet.cell(n, 1).value)
person.setdefault(code, {})
dict1 = {}
dict1['name'] = sheet.cell(n, 3).value
if sheet.cell(n, 4).value ==1:
sex = '男'
else:
sex = '女'
dict1['sex'] = sex
birth = str(sheet.cell(n, 5).value).split()[0]
dict1['birth'] = birth
dict1['unit'] = sheet.cell(n, 2).value
if sheet.cell(n,6).value is not None:
dict1['phone'] = sheet.cell(n, 6).value
person[code] = dict1
filename = 'data/北京农行人员名单2308.json'
with open(filename, 'w') as fl:
json.dump(person, fl, ensure_ascii=False)
print('ok')In [ ]:
import json
import time
import csv
filename = '../item.json'
item = {}
unit = {}
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict1.items():
item[k] = v
re_ta = {}
dict1 = {}
list1 = []
filename = 'data/北京农行人员名单2308.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/places_result_20230825.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
#line = re.sub('[\r\n\f ]{1,}', '', line)
list1.append(line)
#print(list1)
for result in list1:
user = str(result[2])
if user in dict1.keys():
m_item = str(result[3])
re_ta.setdefault(user,{})
re_ta[user]['name'] = dict1[user]['name']
re_ta[user]['sex'] = dict1[user]['sex']
re_ta[user]['unit'] = dict1[user]['unit']
item_name = item[m_item]['name']
re_ta[user].setdefault(item_name,{})
score = int(result[4])/item[m_item]['divisor']
re_ta[user][item_name]['成绩'] = f'{score} {item[m_item]["unit"]}'
print(len(re_ta))
filename = 'data/result_北京农行0825.json'
with open(filename,'w') as fl:
json.dump(re_ta, fl, ensure_ascii=False)
print(len(re_ta))In [ ]:
import json
import time
import csv
filename = '../item.json'
item = {}
unit = {}
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict1.items():
item[k] = v
re_ta = {}
dict1 = {}
list1 = []
filename = 'data/北京农行人员名单2308.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/places_result_20230825.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
#line = re.sub('[\r\n\f ]{1,}', '', line)
list1.append(line)
#print(list1)
for result in list1:
user = str(result[2])
if user in dict1.keys():
m_item = str(result[3])
re_ta.setdefault(user,{})
re_ta[user]['name'] = dict1[user]['name']
re_ta[user]['sex'] = dict1[user]['sex']
re_ta[user]['unit'] = dict1[user]['unit']
item_name = item[m_item]['name']
re_ta[user].setdefault(item_name,{})
score = int(result[4])/item[m_item]['divisor']
re_ta[user][item_name]['成绩'] = f'{score} {item[m_item]["unit"]}'
print(len(re_ta))
filename = 'data/result_北京农行0825.json'
with open(filename,'w') as fl:
json.dump(re_ta, fl, ensure_ascii=False)
print(len(re_ta))In [ ]:
import json
import time
import csv
filename = 'data/result_北京农行0825.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
i= 0
for k, v in dict1.items():
if len(v.keys())< 8:
print(k,v['name'])In [ ]:
import json
import openpyxl
filename = 'data/result_北京农行0825.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
list1 =[]
for k, v in dict1.items():
list2 = []
list2 = [k,v['name'],v['sex'],v['unit']]
list1.append(list2)
filename = 'data/北京农行测试人员202308.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
for row in list1:
sheet.append(row)
wb.save(filename)In [ ]:
import json
filename = 'data/result_北京农行0825.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
if v['sex'] == '男' and '一分钟仰卧起坐' in v.keys():
print(k,'应为女性!')
if v['sex'] == '女' and '俯卧撑' in v.keys():
print(k,'应为男性!')In [ ]:
import openpyxl
import json
wb = openpyxl.load_workbook('data/北京农行测试人员202308.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
data1 =list(sheet.values)
del data1[0]
list1 = []
for item in data1:
code = int(item[0])
list1.append((309118,code,5,item[4],'2023-08-23','2023-08-23 22:00:00'))
print(list1)In [ ]:
import json
import csv
filename = 'data/北京农行人员名单2308.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/Survey_20230913.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
code = str(line[4])
name = line[3]
if code not in dict1.keys() or name!= dict1[code]['name']:
print(code,name)
In [ ]:
import json
filename = 'data/北京农行人员名单2308.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/北京农行人员名单.json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
for k, v in dict2.items():
dict1[k] = v
filename = 'data/北京农行人员名单all.json'
with open(filename,'w') as fl:
json.dump(dict1, fl, ensure_ascii=False)
print(len(re_ta))In [ ]:
import os,sys,shutil
import json
import glob
from pathlib import Path
fi_path = '/home/songyi/python/mycrm/flask/pdf/files/309118'
new_path = 'file/309118'
old = []
dict2 = {}
filename = 'data/北京农行人员名单all.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
fls = glob.glob(f'{fi_path}/*.pdf')
for fn in fls:
fi_name =Path(fn).stem.split('-')[0]
code = int(fi_name)
unit_path = Path(new_path,dict1[str(code)]['unit'])
unit_path.mkdir(parents = True, exist_ok = True)
n_name = Path(unit_path,Path(fn).stem+'.pdf')
if not os.path.exists(n_name):
shutil.copyfile(fn,n_name)
print(n_name)In [ ]:
import os,sys,shutil
import json
import glob
from pathlib import Path
import openpyxl
fi_path = '/home/songyi/python/mycrm/flask/pdf/files/309118'
new_path = 'file/309118'
list1 = []
filename = 'data/北京农行人员名单all.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
fls = glob.glob(f'{fi_path}/*.pdf')
for fn in fls:
list2 = []
fi_name =Path(fn).stem.split('-')[0]
code = int(fi_name)
unit = dict1[str(code)]['unit']
list2 = [fi_name,Path(fn).stem.split('-')[1],unit]
list1.append(list2)
filename = 'data/北京农行体测报告打印明细表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
sheet.append(title)
for row in list1:
sheet.append(row)
wb.save(filename)
print('ok')In [ ]:
import json
import time
import csv
filename = '../item.json'
item = {}
unit = {}
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict1.items():
item[k] = v
filename = 'data/北京农行人员名单all.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
re_ta = {}
list1 = []
#print("\n运动项目信息:")
filename = 'data/places_result_20230922-1695356859947.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
#line = re.sub('[\r\n\f ]{1,}', '', line)
list1.append(line)
#print(list1)
for result in list1:
user = str(result[2])
if user in dict1.keys():
m_item = str(result[3])
re_ta.setdefault(user,{})
re_ta[user]['name'] = dict1[user]['name']
re_ta[user]['sex'] = dict1[user]['sex']
re_ta[user]['birth'] = dict1[user]['birth'].replace('-','/')
item_name = item[m_item]['name']
re_ta[user].setdefault(item_name,{})
score = int(result[4])/item[m_item]['divisor']
re_ta[user][item_name]['成绩'] = f'{score} {item[m_item]["unit"]}'
re_ta[user][item_name]['得分'] =result[5]
print(len(re_ta))
liwai = []
for k, v in re_ta.items():
if (len(v)<8 and '身高' in v and '体重' in v) or (len(v)<7 and '身高' not in v and '体重' not in v) :
liwai.append(k)
print(liwai)
for k in liwai:
del re_ta[k]
print(len(re_ta))
filename = 'data/result_北京农行all.json'
with open(filename,'w') as fl:
json.dump(re_ta, fl, ensure_ascii=False)
print('ok')
print(len(re_ta))In [ ]:
import json
import datetime
filename = 'data/result_北京农行all.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
#print(k,v)
if '.' in v['birth']:
birth = v['birth'].split()[0].split('.')
else:
birth = v['birth'].split()[0].split('/')
nian = int(birth[0].strip())
yue = int(birth[1].strip())
ri = int(birth[2].strip())
#print(k,nian,yue,ri)
if int(k) < 199:
days = (datetime.date(2023, 5, 11)-datetime.date(nian,yue,ri)).days
else:
days = (datetime.date(2023, 8, 24)-datetime.date(nian,yue,ri)).days
v['age'] = int(days/365)
filename = 'data/result_北京农行all.json'
with open(filename,'w') as fl:
json.dump(dict1, fl, ensure_ascii=False)
print('ok') In [ ]:
import json
items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict1.items():
print(k)
score = 0
i = 0
for k1,v1 in v.items():
if k1 in items:
score = score + int(v1['得分'])
i+=1
dict1[k]['score'] = round(score/i,2)
with open(filename,'w') as fl:
json.dump(dict1, fl, ensure_ascii=False)
print('ok')In [ ]:
import json
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
dict2['不合格'] = [0,255]
dict2['合格'] = [256,332]
dict2['良好'] = [333,367]
dict2['优秀'] = [368,500]
for k1, v1 in dict2.items():
di = v1[0]
gao = v1[1]
i = 0
m = 0
f = 0
for k,v in dict1.items():
if int(v['score']*100) in range(di,gao+1):
dict1[k]['level'] = k1
i+=1
if v['sex'] == '男':
m = m +1
else:
f = f+1
print(f'{di}~{gao}分人数:{i}人,男性:{m}人,女性:{f}人')
with open(filename,'w') as fl:
json.dump(dict1, fl)
print('ok')In [ ]:
import json
nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]
with open(filename,'r') as fl:
dict1 = json.load(fl)
for item in nld:
di = item[0]
gao = item[1]
i = 0
score = 0
m = 0
f = 0
for k,v in dict1.items():
if v['age'] in range(di,gao+1):
score = score+v['score']
i+=1
if v['sex'] == '男':
m = m +1
print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人,男性:{m}人')In [ ]:
import json
nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]
with open(filename,'r') as fl:
dict1 = json.load(fl)
for item in nld:
di = item[0]
gao = item[1]
i = 0
score = 0
m = 0
f = 0
for k,v in dict1.items():
if v['age'] in range(di,gao+1) and v['sex'] == '男':
score = score+v['score']
i+=1
if i >0:
print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人')
else:
print(f'{di}~{gao}岁平均成绩:0分,人数:0人') In [ ]:
import json
nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]
with open(filename,'r') as fl:
dict1 = json.load(fl)
for item in nld:
di = item[0]
gao = item[1]
i = 0
score = 0
m = 0
f = 0
for k,v in dict1.items():
if v['age'] in range(di,gao+1) and v['sex'] == '女':
score = score+v['score']
i+=1
if i >0:
print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人')
else:
print(f'{di}~{gao}岁平均成绩:0分,人数:0人') In [ ]:
import json
nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]
#filename = 'data/result_石家庄.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
i = 1
m = 0
f = 0
score = 0
t_score = 0
for k,v in dict1.items():
if v['sex'] == '男':
m = m +1
score = score+v['score']
print(f'平均成绩:{round(score/m,4)}分,男性:{m}人')
t_score = t_score + score
score = 0
for k,v in dict1.items():
if v['sex'] == '女':
f = f +1
score = score+v['score']
print(f'平均成绩:{round(score/f,4)}分,女性:{f}人')
t_score = t_score + score
print(f'平均成绩:{round(t_score/522,4)}分,总体:522人')In [ ]:
nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
dict2['不合格'] = [0,255]
dict2['合格'] = [256,332]
dict2['良好'] = [333,367]
dict2['优秀'] = [368,500]
dict3 = {}
for item in nld:
di = item[0]
gao = item[1]
age = f'{di}-{gao}'
dict3.setdefault(age,{})
i = 0
m = 0
f = 0
for k,v in dict1.items():
if v['age'] in range(di,gao+1):
dict3[age].setdefault(v['level'],0)
if v['sex'] == '女':
dict3[age][v['level']] = dict3[age][v['level']]+1
for k, v in dict3.items():
print(k,v)In [ ]:
nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
dict2['不合格'] = [0,255]
dict2['合格'] = [256,332]
dict2['良好'] = [333,367]
dict2['优秀'] = [368,500]
dict3 = {}
for item in nld:
di = item[0]
gao = item[1]
age = f'{di}-{gao}'
dict3.setdefault(age,{})
i = 0
m = 0
f = 0
for k,v in dict1.items():
if v['age'] in range(di,gao+1):
dict3[age].setdefault(v['level'],0)
if v['sex'] == '男':
dict3[age][v['level']] = dict3[age][v['level']]+1
for k, v in dict3.items():
print(k,v)In [ ]:
with open(filename,'r') as fl:
dict1 = json.load(fl)
items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']
for item in items:
score = 0
n = 0
for k, v in dict1.items():
if item in v.keys():
n = n + 1
score =score + int(v[item]['得分'])
print(item,round(score/n,2),n)In [ ]:
import json
import openpyxl
filename = 'data/北京农行人员名单all.json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
list1 = ['握力组', '平衡组', '平和质', '气虚质', '阳虚质', '阴虚质', '痰湿质', '湿热质', '血瘀质', '气郁质', '特禀质']
wb = openpyxl.load_workbook('data/北京农行体测分组情况.xlsx')
#sheet = wb.active
#sheets = wb.sheetnames
for item in list1:
sheet = wb[item]
for n in range(2, sheet.max_row+1):
if sheet.cell(n,1).value is not None:
code = int(sheet.cell(n, 1).value)
person.setdefault(code, {})
dict1 = {}
dict1['name'] = dict2[str(code)]['name']
dict1['phone'] = dict2[str(code)]['phone']
dict1['unit'] = item
name = sheet.cell(n, 2).value
person[code] = dict1
filename = 'data/北京农行百日筑基.json'
with open(filename, 'w') as fl:
json.dump(person, fl, ensure_ascii=False)
print('ok')
In [ ]:
import json
item = {
'血瘀质':'term_6547430d71970_aIWYoQ',
'湿热质':'term_6547428956b35_BlEnpY',
'痰湿质':'term_654742123c1bd_hPSDR4',
'气虚质':'term_654741bc7c0fe_bf0PLC',
'气郁质':'term_6547415695b85_5FAHbR',
'阴虚质':'term_654740fdb2e6b_0pBU7m',
'阳虚质':'term_654740777e521_tsKUsG',
'特禀质':'term_65473fd157db4_FmXOE9',
'平和质':'term_65473f50247a5_bGI0dX',
'平衡组':'term_65473efbcc37f_dJgc2H',
'握力组':'term_65472c788dbf6_5Hj3iw'
}
filename = 'data/北京农行百日筑基.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
url = 'https://appvaCALBPV5946.h5.xiaoeknow.com/p/course/camp/'+item[v['unit']]
print(v['unit'],url)In [ ]: