20231122
This commit is contained in:
1 parent
2a3b6a1af7
commit
8432a5940e
2 files changed
+535
-37
No files matched your search
+517
-34
@@ -993,7 +993,7 @@
|
|||||||
"import json\n",
|
"import json\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"wb = openpyxl.load_workbook('data/北海炼化人员信息(2023年).xlsx')\n",
|
"wb = openpyxl.load_workbook('data/北海炼化人员信息(2023年) (更新).xlsx')\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"# sheets = wb.sheetnames\n",
|
"# sheets = wb.sheetnames\n",
|
||||||
"person = {}\n",
|
"person = {}\n",
|
||||||
@@ -1088,7 +1088,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_20231119.csv'\n",
|
"filename = 'data/places_result_20231122.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",
|
||||||
@@ -1378,41 +1378,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 108,
|
"execution_count": null,
|
||||||
"id": "6faef501-54eb-436b-8c51-093a05c38686",
|
"id": "6faef501-54eb-436b-8c51-093a05c38686",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-11-19T04:47:58.763430Z",
|
|
||||||
"iopub.status.busy": "2023-11-19T04:47:58.763036Z",
|
|
||||||
"iopub.status.idle": "2023-11-19T04:47:58.849448Z",
|
|
||||||
"shell.execute_reply": "2023-11-19T04:47:58.848994Z",
|
|
||||||
"shell.execute_reply.started": "2023-11-19T04:47:58.763379Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"18610346996\n",
|
|
||||||
"13210047238\n",
|
|
||||||
"13397798753\n",
|
|
||||||
"17261940944\n",
|
|
||||||
"18177994725\n",
|
|
||||||
"17777918502\n",
|
|
||||||
"19377997709\n",
|
|
||||||
"15677905862\n",
|
|
||||||
"15133906281\n",
|
|
||||||
"15207800631\n",
|
|
||||||
"18177980276\n",
|
|
||||||
"13398691539\n",
|
|
||||||
"18177981289\n",
|
|
||||||
"19377992679\n",
|
|
||||||
"18169792763\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import csv\n",
|
"import csv\n",
|
||||||
@@ -1446,10 +1417,522 @@
|
|||||||
" "
|
" "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "95e2d0f2-c0c7-4647-a34d-1b998ca89293",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 统计各部门测试情况"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 130,
|
||||||
|
"id": "d554c400-8f2f-4f60-97ba-ab5ace254d6f",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-22T02:55:08.341413Z",
|
||||||
|
"iopub.status.busy": "2023-11-22T02:55:08.340762Z",
|
||||||
|
"iopub.status.idle": "2023-11-22T02:55:08.418936Z",
|
||||||
|
"shell.execute_reply": "2023-11-22T02:55:08.417041Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-22T02:55:08.341353Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_北海炼化2023.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/北海炼化2023年.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" unit = v['unit']\n",
|
||||||
|
" #sub_unit = v['sub_unit']\n",
|
||||||
|
" dict3.setdefault(unit,{})\n",
|
||||||
|
" dict3[unit].setdefault('人数',0)\n",
|
||||||
|
" #dict3[unit].setdefault(sub_unit,0)\n",
|
||||||
|
" #dict3[unit][sub_unit] = dict3[unit][sub_unit] + 1\n",
|
||||||
|
" dict3[unit]['人数'] = dict3[unit]['人数'] + 1\n",
|
||||||
|
"\n",
|
||||||
|
"title =['单位','体测人数']\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k,v in dict1.items(): \n",
|
||||||
|
" unit = v['unit']\n",
|
||||||
|
" #sub_unit = v['sub_unit']\n",
|
||||||
|
" #dict3[unit][sub_unit] = dict3[unit][sub_unit] - 1\n",
|
||||||
|
" dict3[unit].setdefault('体测人数',0)\n",
|
||||||
|
" dict3[unit]['体测人数'] = dict3[unit]['体测人数'] + 1\n",
|
||||||
|
"for k, v in dict3.items():\n",
|
||||||
|
" list2 = [k,v['人数'],v['体测人数']]\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/北海炼化部门测试情况.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": "14101d8f-4e74-4982-a984-c0ebe4099107",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成新格式测试成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 122,
|
||||||
|
"id": "f21b1c8d-1b2d-45f6-8f35-4a62d5b944f7",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-22T02:46:15.092874Z",
|
||||||
|
"iopub.status.busy": "2023-11-22T02:46:15.092396Z",
|
||||||
|
"iopub.status.idle": "2023-11-22T02:46:15.175664Z",
|
||||||
|
"shell.execute_reply": "2023-11-22T02:46:15.174984Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-22T02:46:15.092847Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"697\n",
|
||||||
|
"697\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import datetime\n",
|
||||||
|
"import csv\n",
|
||||||
|
"from datetime import date\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",
|
||||||
|
"item['1']['en'] = 'lung'\n",
|
||||||
|
"item['2']['en'] = 'grip'\n",
|
||||||
|
"item['3']['en'] = 'flexion'\n",
|
||||||
|
"item['4']['en'] = 'jump'\n",
|
||||||
|
"item['5']['en'] = 'pushup'\n",
|
||||||
|
"item['6']['en'] = 'balance'\n",
|
||||||
|
"item['7']['en'] = 'reaction'\n",
|
||||||
|
"item['8']['en'] = 'step'\n",
|
||||||
|
"item['9']['en'] = 'situp'\n",
|
||||||
|
"item['10']['en'] = 'height'\n",
|
||||||
|
"item['11']['en'] = 'weight'\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"re_ta = {}\n",
|
||||||
|
"dict1 = {}\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/北海炼化2023年.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/places_result_20231122.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",
|
||||||
|
"#f_item = ['lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
||||||
|
"#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
||||||
|
"for result in list1:\n",
|
||||||
|
" user = str(result[2])\n",
|
||||||
|
" rq = date.fromisoformat(result[6].replace('/','-'))\n",
|
||||||
|
" if user in dict1.keys():\n",
|
||||||
|
" l_xm = []\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]['phone'] = dict1[user]['phone']\n",
|
||||||
|
" if dict1[user]['sex'] == '男':\n",
|
||||||
|
" l_xm = ['weight','height','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
||||||
|
" else:\n",
|
||||||
|
" l_xm = ['weight','height','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
||||||
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
||||||
|
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
|
||||||
|
" #nian = int(birth[0].strip())\n",
|
||||||
|
" #yue = int(birth[1].strip())\n",
|
||||||
|
" #ri = int(birth[2].strip())\n",
|
||||||
|
" #print(k,nian,yue,ri)\n",
|
||||||
|
" item_name = item[m_item]['en'] \n",
|
||||||
|
" if item_name in l_xm: \n",
|
||||||
|
" days = (rq-birth).days \n",
|
||||||
|
" re_ta[user]['age'] = int(days/365)\n",
|
||||||
|
" re_ta[user]['month'] = int(days/365*12)\n",
|
||||||
|
" re_ta[user]['rq'] = result[6]\n",
|
||||||
|
"\n",
|
||||||
|
"\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_北海炼化2023.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": "89a02e6b-0418-4516-a9e0-12364aa38783",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成测试得分"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 123,
|
||||||
|
"id": "9ca97d8f-6320-48f1-9a16-2d34167dac19",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-22T02:46:23.851352Z",
|
||||||
|
"iopub.status.busy": "2023-11-22T02:46:23.850893Z",
|
||||||
|
"iopub.status.idle": "2023-11-22T02:46:23.961867Z",
|
||||||
|
"shell.execute_reply": "2023-11-22T02:46:23.961246Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-22T02:46:23.851325Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok!\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import time\n",
|
||||||
|
"\n",
|
||||||
|
"filename = '../item.json'\n",
|
||||||
|
"item = {}\n",
|
||||||
|
"unit = {}\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict3 = json.load(fl) \n",
|
||||||
|
"for k,v in dict3.items():\n",
|
||||||
|
" item[k] = v\n",
|
||||||
|
"item['1']['en'] = 'lung'\n",
|
||||||
|
"item['2']['en'] = 'grip'\n",
|
||||||
|
"item['3']['en'] = 'flexion'\n",
|
||||||
|
"item['4']['en'] = 'jump'\n",
|
||||||
|
"item['5']['en'] = 'pushup'\n",
|
||||||
|
"item['6']['en'] = 'balance'\n",
|
||||||
|
"item['7']['en'] = 'reaction'\n",
|
||||||
|
"item['8']['en'] = 'step'\n",
|
||||||
|
"item['9']['en'] = 'situp'\n",
|
||||||
|
"item['10']['en'] = 'height'\n",
|
||||||
|
"item['11']['en'] = 'weight'\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/体质检测标准 (1).json' \n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"def cal_score(data1):\n",
|
||||||
|
" #data = {'name':'张三','sex':'M','age':37,'item':'StepExperiment','result':46} \n",
|
||||||
|
" person = dict1['person']\n",
|
||||||
|
" criteria = dict1['criteria']\n",
|
||||||
|
" if data1['age'] >59:\n",
|
||||||
|
" data1['age'] = 59\n",
|
||||||
|
" if data1['age'] <20:\n",
|
||||||
|
" data1['age'] = 20\n",
|
||||||
|
" info = data1['sex']+str(data1['age'])\n",
|
||||||
|
" bz = person[info]\n",
|
||||||
|
" mx = criteria[bz][data1['item']]\n",
|
||||||
|
" result = data1['result'] \n",
|
||||||
|
" if data1['item'] == 'reaction':\n",
|
||||||
|
" for bz1 in mx:\n",
|
||||||
|
" if result > bz1:\n",
|
||||||
|
" #print(bz1)\n",
|
||||||
|
" score = mx.index(bz1,0)\n",
|
||||||
|
" break\n",
|
||||||
|
" else:\n",
|
||||||
|
" score = 5\n",
|
||||||
|
" else:\n",
|
||||||
|
" for bz1 in mx:\n",
|
||||||
|
" if result < bz1:\n",
|
||||||
|
" #print(bz1)\n",
|
||||||
|
" score = mx.index(bz1,0)\n",
|
||||||
|
" break\n",
|
||||||
|
" else:\n",
|
||||||
|
" score = 5\n",
|
||||||
|
" return(score)\n",
|
||||||
|
"filename = 'data/体质检测标准_BMI.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict4 = json.load(fl) \n",
|
||||||
|
" \n",
|
||||||
|
"def cal_bmi(data1):\n",
|
||||||
|
" # data = {'name':'张三','sex':'M','age':37,'item':'HeightWeight','result':'177.7,97.0'}\n",
|
||||||
|
" person = dict4['person']\n",
|
||||||
|
" criteria = dict4['criteria']\n",
|
||||||
|
" if data1['age'] > 59:\n",
|
||||||
|
" data1['age'] = 59\n",
|
||||||
|
" if data1['age'] <20:\n",
|
||||||
|
" data1['age'] = 20\n",
|
||||||
|
" info = data1['sex']+str(data1['age'])\n",
|
||||||
|
" bz = person[info]\n",
|
||||||
|
" #print(bz)\n",
|
||||||
|
" result = data1['result']\n",
|
||||||
|
" #print(data1['code'],result)\n",
|
||||||
|
" height = int(float(result.split(',')[0]))\n",
|
||||||
|
" weight = float(result.split(',')[1])\n",
|
||||||
|
" if str(height) not in criteria[bz]:\n",
|
||||||
|
" score = 1\n",
|
||||||
|
" else: \n",
|
||||||
|
" mx = criteria[bz][str(height)]\n",
|
||||||
|
" if weight < mx[0]:\n",
|
||||||
|
" score = 1\n",
|
||||||
|
" elif weight < mx[1]:\n",
|
||||||
|
" score = 3\n",
|
||||||
|
" elif weight < mx[2]:\n",
|
||||||
|
" score = 5 \n",
|
||||||
|
" elif weight <= mx[3]:\n",
|
||||||
|
" score = 3 \n",
|
||||||
|
" elif weight > mx[3]:\n",
|
||||||
|
" score = 1\n",
|
||||||
|
" return score\n",
|
||||||
|
" \n",
|
||||||
|
" \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']\n",
|
||||||
|
"filename = 'data/result_北海炼化2023.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl) \n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" #print(k)\n",
|
||||||
|
" if v['sex'] == '男':\n",
|
||||||
|
" sex = 'M'\n",
|
||||||
|
" else:\n",
|
||||||
|
" sex = 'F' \n",
|
||||||
|
" if 'height' in v.keys() and 'weight' in v.keys():\n",
|
||||||
|
" bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
|
||||||
|
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':'HeightWeight','result':bmi_data}\n",
|
||||||
|
" dict2[k]['bmi'] = {}\n",
|
||||||
|
" dict2[k]['bmi']['成绩'] = bmi_data\n",
|
||||||
|
" dict2[k]['bmi']['score'] = cal_bmi(data1)\n",
|
||||||
|
" for item_en in list_item:\n",
|
||||||
|
" if item_en in v.keys(): \n",
|
||||||
|
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':item_en,'result':float(v[item_en]['成绩'].split()[0])}\n",
|
||||||
|
" #print(k,v['name'])\n",
|
||||||
|
" dict2[k][item_en]['score'] = cal_score(data1)\n",
|
||||||
|
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||||||
|
"\n",
|
||||||
|
"filename = f'data/result_北海炼化2023.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||||
|
"print('ok!') "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "abace6bc-9c99-497d-a1c1-9ff045ccfc03",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成体测成绩明细表"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 132,
|
||||||
|
"id": "f0608de5-07ae-458c-999e-60968314f058",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-22T03:00:59.351223Z",
|
||||||
|
"iopub.status.busy": "2023-11-22T03:00:59.350945Z",
|
||||||
|
"iopub.status.idle": "2023-11-22T03:00:59.703401Z",
|
||||||
|
"shell.execute_reply": "2023-11-22T03:00:59.702798Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-22T03:00:59.351200Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||||
|
"bmi = ['height','weight']\n",
|
||||||
|
"title = ['编号','姓名','性别','单位/部门','身高','体重','bmi','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_北海炼化2023.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k, v in dict1.items(): #print(k,dict2[str(k)]['name'])\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" list2.append(str(k).rjust(5,'0'))\n",
|
||||||
|
" list2.append(dict1[k]['name']) \n",
|
||||||
|
" list2.append(dict1[k]['sex'])\n",
|
||||||
|
" list2.append(dict1[k]['unit'])\n",
|
||||||
|
" list2.append(dict1[k]['phone'])\n",
|
||||||
|
" i = 0\n",
|
||||||
|
" if 'bmi' in dict1[k].keys():\n",
|
||||||
|
" list2.append(dict1[k]['height']['成绩'])\n",
|
||||||
|
" list2.append(dict1[k]['weight']['成绩'])\n",
|
||||||
|
" list2.append(dict1[k]['bmi']['score'])\n",
|
||||||
|
" i+=1\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('') \n",
|
||||||
|
" list2.append('') \n",
|
||||||
|
" list2.append('') \n",
|
||||||
|
" \n",
|
||||||
|
" \n",
|
||||||
|
" for item in items:\n",
|
||||||
|
" if item in dict1[k].keys():\n",
|
||||||
|
" list2.append(dict1[k][item]['成绩'])\n",
|
||||||
|
" list2.append(dict1[k][item]['score']) \n",
|
||||||
|
" i+=1\n",
|
||||||
|
" elif item =='name':\n",
|
||||||
|
" list2.append(dict1[k][item])\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('') \n",
|
||||||
|
" list2.append('') \n",
|
||||||
|
" if i>2:\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"filename = 'data/北海炼化体测情况表.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)\n",
|
||||||
|
"print('ok') "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "5f46d541-c7db-4adf-b452-d901c757e9c5",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 查询参加问卷未参加体测人员"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 134,
|
||||||
|
"id": "2c867c7f-00b4-4a41-a6eb-18d6c39fa4cc",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-22T03:28:56.932672Z",
|
||||||
|
"iopub.status.busy": "2023-11-22T03:28:56.932375Z",
|
||||||
|
"iopub.status.idle": "2023-11-22T03:28:56.981535Z",
|
||||||
|
"shell.execute_reply": "2023-11-22T03:28:56.980516Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-22T03:28:56.932646Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"18777937356\n",
|
||||||
|
"13768090960\n",
|
||||||
|
"18977916950\n",
|
||||||
|
"18277917797\n",
|
||||||
|
"18092434264\n",
|
||||||
|
"13977982222\n",
|
||||||
|
"13877944139\n",
|
||||||
|
"13517796512\n",
|
||||||
|
"13977933993\n",
|
||||||
|
"15613726645\n",
|
||||||
|
"13877935443\n",
|
||||||
|
"13768091811\n",
|
||||||
|
"13877923030\n",
|
||||||
|
"18092434264\n",
|
||||||
|
"18992865291\n",
|
||||||
|
"15577993102\n",
|
||||||
|
"18277917797\n",
|
||||||
|
"13977990782\n",
|
||||||
|
"18177980276\n",
|
||||||
|
"15224521321\n",
|
||||||
|
"18822081130\n",
|
||||||
|
"13807898246\n",
|
||||||
|
"18277917797\n",
|
||||||
|
"13768091811\n",
|
||||||
|
"13517790009\n",
|
||||||
|
"15143256015\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import csv\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import time\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_北海炼化2023.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/北海炼化2023年.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict3 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"phone = set()\n",
|
||||||
|
"phone1 = set()\n",
|
||||||
|
"for k,v in dict3.items():\n",
|
||||||
|
" phone.add(v['phone'])\n",
|
||||||
|
"for k,v in dict1.items():\n",
|
||||||
|
" phone1.add(v['phone'])\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/Survey_20231122.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",
|
||||||
|
" list1.append(line)\n",
|
||||||
|
"\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" if item[2] in phone and item[2] not in phone1:\n",
|
||||||
|
" print(item[2])\n",
|
||||||
|
" "
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "d206f455-8563-405e-a00f-e8f055e266a0",
|
"id": "01444d7a-0a47-4cc4-881b-783100553cc1",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
+18
-3
@@ -1221,12 +1221,27 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 27,
|
||||||
"id": "dcdd18b3-d7b7-49b1-b148-c2ea9a7799ff",
|
"id": "dcdd18b3-d7b7-49b1-b148-c2ea9a7799ff",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-21T03:09:53.451357Z",
|
||||||
|
"iopub.status.busy": "2023-11-21T03:09:53.450510Z",
|
||||||
|
"iopub.status.idle": "2023-11-21T03:09:53.535389Z",
|
||||||
|
"shell.execute_reply": "2023-11-21T03:09:53.534089Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-21T03:09:53.451280Z"
|
||||||
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"3\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import csv\n",
|
"import csv\n",
|
||||||
@@ -1240,7 +1255,7 @@
|
|||||||
"wj_dm = {'psy_0556_sh':0,'tcm_0556_sh':1,'spine_0556_sh':2}\n",
|
"wj_dm = {'psy_0556_sh':0,'tcm_0556_sh':1,'spine_0556_sh':2}\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"re_ta = {}\n",
|
"re_ta = {}\n",
|
||||||
"filename = 'data/Survey_20231023.csv'\n",
|
"filename = 'data/Survey_20231121.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",
|
||||||
|
|||||||
Reference in new issue
Block a user