250251215

This commit is contained in:
512song committed 2025-12-15 08:11:54 +08:00
1 parent c19ca272d7
commit 6803e6fff6
6 files changed
+1464 -620

No files matched your search

+296 -19
View File
@@ -63,6 +63,59 @@
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "27a49c91-b122-47cf-806a-6b252787b2db",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:13:24.043753Z",
"iopub.status.busy": "2025-12-12T13:13:24.042051Z",
"iopub.status.idle": "2025-12-12T13:13:24.065063Z",
"shell.execute_reply": "2025-12-12T13:13:24.064583Z",
"shell.execute_reply.started": "2025-12-12T13:13:24.043682Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12\n",
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/东营油田老年大学体质检测名单(2512).xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,1).value is not None:\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'] = ''\n",
" dict1['birth'] = str(sheet.cell(n, 4).value).replace('/','-').split(' ')[0]\n",
" #dict1['age'] = sheet.cell(n, 6).value\n",
" if sheet.cell(n,5).value is not None:\n",
" dict1['phone'] = str(sheet.cell(n,5).value) \n",
" person[code] = dict1\n",
"filename = 'data/油田老年大学2025年度体质复测.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person))\n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": 88,
@@ -341,6 +394,85 @@
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "dcc5a261-35ef-48c2-b4dd-618f417e45dc",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:13:33.184367Z",
"iopub.status.busy": "2025-12-12T13:13:33.183622Z",
"iopub.status.idle": "2025-12-12T13:13:33.204374Z",
"shell.execute_reply": "2025-12-12T13:13:33.203788Z",
"shell.execute_reply.started": "2025-12-12T13:13:33.184296Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12\n"
]
}
],
"source": [
"import json\n",
"import datetime\n",
"import csv\n",
"from datetime import date\n",
"\n",
"\n",
"re_ta = {}\n",
"list1 = []\n",
"filename = 'data/油田老年大学2025年度体质复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/marks_20251212.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",
"\n",
"for result in list1:\n",
" user = str(result[2])\n",
" rq = date.fromisoformat(result[5].replace('/','-'))\n",
" if user in dict1.keys():\n",
" #print(user)\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]['birth'] = dict1[user]['birth']\n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" if 'phone' in dict1[user].keys():\n",
" re_ta[user]['phone'] = dict1[user]['phone']\n",
" if dict1[user]['sex'] == '男':\n",
" l_xm = ['bmi','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
" else:\n",
" l_xm = ['bmi','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",
" item_name = result[3] \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[5]\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = result[4] \n",
" re_ta[user][item_name]['成绩'] = score\n",
"\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\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": "74ec60b7-b1d9-488d-95fa-4ddd020c2a4c",
@@ -351,15 +483,15 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 26,
"id": "c3b99428-00d5-45ea-9803-261194525fa4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-07T12:39:35.778154Z",
"iopub.status.busy": "2025-04-07T12:39:35.777362Z",
"iopub.status.idle": "2025-04-07T12:39:35.793555Z",
"shell.execute_reply": "2025-04-07T12:39:35.792548Z",
"shell.execute_reply.started": "2025-04-07T12:39:35.778096Z"
"iopub.execute_input": "2025-12-12T13:13:35.809342Z",
"iopub.status.busy": "2025-12-12T13:13:35.808036Z",
"iopub.status.idle": "2025-12-12T13:13:35.820106Z",
"shell.execute_reply": "2025-12-12T13:13:35.818957Z",
"shell.execute_reply.started": "2025-12-12T13:13:35.809273Z"
}
},
"outputs": [
@@ -378,7 +510,7 @@
"\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_陈庄检测人员-2.json'\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for k, v in dict2.items():\n",
@@ -401,7 +533,7 @@
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"\n",
"filename = f'data/result_陈庄检测人员-2.json'\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
@@ -874,6 +1006,142 @@
" json.dump(dict1, fl, ensure_ascii=False) "
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "0ba2e1a3-78c8-44d9-ab7d-b17b52b0a99f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:38:13.857680Z",
"iopub.status.busy": "2025-12-12T13:38:13.856977Z",
"iopub.status.idle": "2025-12-12T13:38:13.880423Z",
"shell.execute_reply": "2025-12-12T13:38:13.879532Z",
"shell.execute_reply.started": "2025-12-12T13:38:13.857614Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"15684378667\n",
"15684378667\n",
"13699180673\n",
"15105461296\n",
"13012909096\n",
"13954605763\n",
"13287350839\n",
"13561090015\n",
"13287336162\n",
"13963396946\n",
"15105461298\n",
"13864739068\n",
"13013569039\n",
"13864757610\n",
"15725185717\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"dict1 = {}\n",
"\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"\n",
"\n",
"list1 = []\n",
"filename = 'data/sql_20251212.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",
"#print(list1)\n",
"dict2 = {}\n",
"\n",
"for item in list1:\n",
" psy = []\n",
" tcm = []\n",
" spine = []\n",
" for i in range(0,30):\n",
" psy.append(0)\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" phone = item[0][2:]\n",
" print(phone)\n",
" for k1, v1 in dict3.items():\n",
" if 'phone' in v1.keys() and phone ==v1['phone']: \n",
" dict1[k1] = dict3[k1]\n",
" #dict1[k1]['month'] = dict1[k1]['age'] *12\n",
"for item in list1:\n",
" #print(item)\n",
" psy = []\n",
" tcm = []\n",
" spine = []\n",
" for i in range(0,30):\n",
" psy.append(0)\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" phone = item[0][2:]\n",
" for k1, v1 in dict1.items():\n",
" #print((k1,v1))\n",
" if 'phone' in v1.keys() and phone ==v1['phone']: \n",
" content = json.loads(item[1])\n",
" #print(content)\n",
" \n",
" rq = date.fromisoformat(item[2].replace('/','-').split(' ')[0])\n",
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
" for k, v in json.loads(content).items():\n",
" #print('k:',k,'v:',v)\n",
" if 'psyOld' in k: \n",
" i = int(k[6:])\n",
" psy[i-1] = int(v)\n",
" if 'tcm' in k: \n",
" i = int(k[3:])\n",
" tcm[i-1] = int(v)\n",
" if 'spine' in k:\n",
" i = int(k[5:])\n",
" spine[i-1] = int(v)\n",
" if 'psyOld' in item[1]:\n",
" \n",
" dict1[k1]['psy_yangmiao_old'] = psy\n",
" if 'tcm' in item[1]:\n",
" \n",
" dict1[k1]['tcm'] = tcm\n",
" if 'spine' in item[1]:\n",
" for ii in range(25,23,-1):\n",
" \n",
" spine[ii] = spine[ii-1]\n",
" \n",
" spine[22] = 0\n",
" \n",
" \n",
" \n",
" dict1[k1]['spine'] = spine\n",
" #birth = date.fromisoformat(dict3[k1]['birth'].replace('/','-'))\n",
"\n",
" #days = (rq-birth).days \n",
" #dict1[k1]['age'] = int(days/365)\n",
" \n",
" dict1[k1]['rq'] = item[2].replace('/','-').split(' ')[0]\n",
"#print(dict1)\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "85d087e3-c469-409e-893b-a22789d73613",
@@ -1037,15 +1305,15 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 36,
"id": "7ee80847-2bc0-4cbe-9534-c5dcf97c2833",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-07T12:40:25.086716Z",
"iopub.status.busy": "2025-04-07T12:40:25.086178Z",
"iopub.status.idle": "2025-04-07T12:40:51.228212Z",
"shell.execute_reply": "2025-04-07T12:40:51.227012Z",
"shell.execute_reply.started": "2025-04-07T12:40:25.086666Z"
"iopub.execute_input": "2025-12-12T13:38:35.200844Z",
"iopub.status.busy": "2025-12-12T13:38:35.200220Z",
"iopub.status.idle": "2025-12-12T13:38:42.941941Z",
"shell.execute_reply": "2025-12-12T13:38:42.941270Z",
"shell.execute_reply.started": "2025-12-12T13:38:35.200787Z"
}
},
"outputs": [
@@ -1053,7 +1321,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"56\n"
"12\n"
]
}
],
@@ -1066,11 +1334,11 @@
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_陈庄检测人员-2.json'\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./东营陈庄2/'\n",
"file_path ='./油田老年大学年度体质复测/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"list2 = []\n",
@@ -1080,7 +1348,7 @@
" \n",
" id = str(k).rjust(4,\"0\")\n",
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
" mydata['title'] = '山东东营陈庄镇'\n",
" mydata['title'] = '油田老年大学年度体质复测'\n",
" mydata['subtitle'] = v['unit']\n",
" mydata['id'] = id\n",
" mydata['name'] = v['name']\n",
@@ -1090,7 +1358,15 @@
" mydata['gender'] = 'female'\n",
" \n",
" mydata['month'] = v['month']\n",
" mydata['fits'] = {}\n",
" survey_list = ['tcm','psy_yangmiao_old','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",
@@ -1100,7 +1376,8 @@
" mark = v[item]['成绩'].split()[0]\n",
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
" #if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n",
" if len(mydata['fits']) >2 : \n",
" #if len(mydata['fits']) >2 : \n",
" if len(mydata['fits']) >2 or 'surveys' in mydata.keys():\n",
" list1.append(mydata)\n",
" list2.append([k,v['name']])\n",
" i+=1\n",