20250304
This commit is contained in:
1 parent
82acaa07a8
commit
4da01b8af8
3 files changed
+902
-277
No files matched your search
+487
-97
@@ -10,15 +10,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 58,
|
||||
"execution_count": 41,
|
||||
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-23T05:16:55.108154Z",
|
||||
"iopub.status.busy": "2024-12-23T05:16:55.107437Z",
|
||||
"iopub.status.idle": "2024-12-23T05:16:55.138579Z",
|
||||
"shell.execute_reply": "2024-12-23T05:16:55.138007Z",
|
||||
"shell.execute_reply.started": "2024-12-23T05:16:55.108086Z"
|
||||
"iopub.execute_input": "2025-03-03T06:31:35.177159Z",
|
||||
"iopub.status.busy": "2025-03-03T06:31:35.176415Z",
|
||||
"iopub.status.idle": "2025-03-03T06:31:35.214675Z",
|
||||
"shell.execute_reply": "2025-03-03T06:31:35.214069Z",
|
||||
"shell.execute_reply.started": "2025-03-03T06:31:35.177089Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
@@ -61,6 +61,63 @@
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 57,
|
||||
"id": "5a98acbe-5f00-4ee0-99b2-7ff8d0caa3bc",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-03-04T01:28:11.977681Z",
|
||||
"iopub.status.busy": "2025-03-04T01:28:11.976966Z",
|
||||
"iopub.status.idle": "2025-03-04T01:28:12.007482Z",
|
||||
"shell.execute_reply": "2025-03-04T01:28:12.006967Z",
|
||||
"shell.execute_reply.started": "2025-03-04T01:28:11.977599Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"125\n",
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/陈庄检测人员登记表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" code = int(sheet.cell(n, 1).value)\n",
|
||||
" person.setdefault(code, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||||
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||||
" dict1['unit'] = sheet.cell(n, 7).value\n",
|
||||
" if sheet.cell(n,7).value is not None:\n",
|
||||
" dict1['unit'] = str(sheet.cell(n,7).value) \n",
|
||||
" else:\n",
|
||||
" dict1['unit'] = ' ' \n",
|
||||
" dict1['birth'] = str(sheet.cell(n, 4).value).replace('/','-').split(' ')[0]\n",
|
||||
" if sheet.cell(n,5).value is not None:\n",
|
||||
" dict1['phone'] = str(sheet.cell(n,5).value) \n",
|
||||
" if sheet.cell(n,6).value is not None:\n",
|
||||
" dict1['id'] = str(sheet.cell(n,6).value) \n",
|
||||
" person[code] = dict1\n",
|
||||
"filename = 'data/陈庄检测人员.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||
"print(len(person))\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
|
||||
@@ -71,27 +128,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 51,
|
||||
"execution_count": null,
|
||||
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-23T02:18:32.436129Z",
|
||||
"iopub.status.busy": "2024-12-23T02:18:32.435385Z",
|
||||
"iopub.status.idle": "2024-12-23T02:18:32.449327Z",
|
||||
"shell.execute_reply": "2024-12-23T02:18:32.448323Z",
|
||||
"shell.execute_reply.started": "2024-12-23T02:18:32.436058Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"67\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import datetime\n",
|
||||
@@ -148,6 +190,84 @@
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 58,
|
||||
"id": "e2526429-e779-4ec5-8a0e-bea623f54f29",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-03-04T01:28:20.346704Z",
|
||||
"iopub.status.busy": "2025-03-04T01:28:20.345188Z",
|
||||
"iopub.status.idle": "2025-03-04T01:28:20.368327Z",
|
||||
"shell.execute_reply": "2025-03-04T01:28:20.367809Z",
|
||||
"shell.execute_reply.started": "2025-03-04T01:28:20.346598Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"115\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/陈庄检测人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"filename = 'data/marks_20250304.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",
|
||||
" 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",
|
||||
@@ -158,15 +278,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 52,
|
||||
"execution_count": 59,
|
||||
"id": "c3b99428-00d5-45ea-9803-261194525fa4",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-23T02:18:35.914475Z",
|
||||
"iopub.status.busy": "2024-12-23T02:18:35.913744Z",
|
||||
"iopub.status.idle": "2024-12-23T02:18:35.934796Z",
|
||||
"shell.execute_reply": "2024-12-23T02:18:35.933710Z",
|
||||
"shell.execute_reply.started": "2024-12-23T02:18:35.914405Z"
|
||||
"iopub.execute_input": "2025-03-04T01:28:24.460728Z",
|
||||
"iopub.status.busy": "2025-03-04T01:28:24.459968Z",
|
||||
"iopub.status.idle": "2025-03-04T01:28:24.473509Z",
|
||||
"shell.execute_reply": "2025-03-04T01:28:24.472999Z",
|
||||
"shell.execute_reply.started": "2025-03-04T01:28:24.460657Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -185,7 +305,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_北体体质康健班202412.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",
|
||||
@@ -208,7 +328,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_北体体质康健班202412.json'\n",
|
||||
"filename = f'data/result_陈庄检测人员.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||
"print('ok!') "
|
||||
@@ -224,15 +344,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 53,
|
||||
"execution_count": 60,
|
||||
"id": "0c60a509-dfc0-426a-a44e-e9a760139463",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-23T02:18:43.101468Z",
|
||||
"iopub.status.busy": "2024-12-23T02:18:43.100822Z",
|
||||
"iopub.status.idle": "2024-12-23T02:18:43.133068Z",
|
||||
"shell.execute_reply": "2024-12-23T02:18:43.132432Z",
|
||||
"shell.execute_reply.started": "2024-12-23T02:18:43.101408Z"
|
||||
"iopub.execute_input": "2025-03-04T01:28:32.981359Z",
|
||||
"iopub.status.busy": "2025-03-04T01:28:32.980597Z",
|
||||
"iopub.status.idle": "2025-03-04T01:28:33.024339Z",
|
||||
"shell.execute_reply": "2025-03-04T01:28:33.023768Z",
|
||||
"shell.execute_reply.started": "2025-03-04T01:28:32.981288Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
@@ -244,11 +364,11 @@
|
||||
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"\n",
|
||||
"filename = 'data/result_北体体质康健班202412.json'\n",
|
||||
"filename = 'data/result_陈庄检测人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/北体体质康健班202412.json'\n",
|
||||
"filename = 'data/陈庄检测人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
" \n",
|
||||
@@ -276,7 +396,7 @@
|
||||
" list2.append('')\n",
|
||||
" \n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/北体体质康健班体测情况表202412.xlsx'\n",
|
||||
"filename = 'data/陈庄检测人员20250303.xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
@@ -296,27 +416,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 49,
|
||||
"execution_count": null,
|
||||
"id": "79fb7799-3693-4b7b-ae82-c0d8dee98d36",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-22T07:18:34.575061Z",
|
||||
"iopub.status.busy": "2024-12-22T07:18:34.574259Z",
|
||||
"iopub.status.idle": "2024-12-22T07:18:34.606759Z",
|
||||
"shell.execute_reply": "2024-12-22T07:18:34.606260Z",
|
||||
"shell.execute_reply.started": "2024-12-22T07:18:34.574981Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"71\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
@@ -326,10 +431,10 @@
|
||||
"\n",
|
||||
"dict1 = {}\n",
|
||||
"\n",
|
||||
"filename = 'data/result_北体体质康健班202412.json'\n",
|
||||
"filename = 'data/result_陈庄检测人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"filename = 'data/北体体质康健班202412.json'\n",
|
||||
"filename = 'data/陈庄检测人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"\n",
|
||||
@@ -339,7 +444,7 @@
|
||||
" phone[v['phone']] = k\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20241220.csv'\n",
|
||||
"filename = 'data/Survey_20250303.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -348,7 +453,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"nn = 0\n",
|
||||
"for item in list1:\n",
|
||||
" if item[2] in phone.keys():\n",
|
||||
" psy =[]\n",
|
||||
@@ -400,11 +505,120 @@
|
||||
" days = (rq-birth).days \n",
|
||||
" dict1[phone[item[2]]]['age'] = int(days/365)\n",
|
||||
" dict1[phone[item[2]]]['month'] = int(days/365*12)\n",
|
||||
"filename = 'data/result_北体体质康健班202412-1.json'\n",
|
||||
" #print(phone[item[2]])\n",
|
||||
" nn+=1\n",
|
||||
"filename = 'data/result_陈庄检测人员-1.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||
"print(len(dict1))"
|
||||
"print(nn)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 61,
|
||||
"id": "891347c4-cd65-41f8-b5dd-b3ff3d1e249f",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-03-04T01:34:28.818217Z",
|
||||
"iopub.status.busy": "2025-03-04T01:34:28.817471Z",
|
||||
"iopub.status.idle": "2025-03-04T01:34:28.854884Z",
|
||||
"shell.execute_reply": "2025-03-04T01:34:28.854277Z",
|
||||
"shell.execute_reply.started": "2025-03-04T01:34:28.818153Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"83\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",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"filename = 'data/陈庄检测人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone = {}\n",
|
||||
"for k,v in dict3.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone[v['phone']] = k\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20250303.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",
|
||||
"\n",
|
||||
"\n",
|
||||
"nn = 0\n",
|
||||
"for item in list1:\n",
|
||||
" if item[2] in phone.keys():\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",
|
||||
" \n",
|
||||
" content = json.loads(item[5])\n",
|
||||
" if phone[item[2]] not in dict1.keys():\n",
|
||||
" dict1[phone[item[2]]] = dict3[phone[item[2]]]\n",
|
||||
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||||
" dict1[phone[item[2]]]['rq'] = item[6].replace('/','-').split(' ')[0]\n",
|
||||
" for k, v in content.items():\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[5]:\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" dict1[phone[item[2]]]['psy_yangmiao_old'] = psy\n",
|
||||
" if 'tcm' in item[5]:\n",
|
||||
" \n",
|
||||
" dict1[phone[item[2]]]['tcm'] = tcm\n",
|
||||
" if 'spine' in item[5]:\n",
|
||||
" for ii in range(25,23,-1):\n",
|
||||
" spine[ii] = spine[ii-1]\n",
|
||||
" spine[22] = 0 \n",
|
||||
" dict1[phone[item[2]]]['spine'] = spine\n",
|
||||
" birth = date.fromisoformat(dict3[phone[item[2]]]['birth'].replace('/','-'))\n",
|
||||
" \n",
|
||||
" days = (rq-birth).days \n",
|
||||
" dict1[phone[item[2]]]['age'] = int(days/365)\n",
|
||||
" dict1[phone[item[2]]]['month'] = int(days/365*12)\n",
|
||||
" #print(phone[item[2]])\n",
|
||||
" nn+=1\n",
|
||||
"filename = 'data/result_陈庄检测人员-1.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||
"print(nn)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -468,16 +682,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": null,
|
||||
"id": "eb4091f4-9823-4361-acb2-f3e898f9524b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-22T00:37:03.115402Z",
|
||||
"iopub.status.busy": "2024-12-22T00:37:03.114604Z",
|
||||
"iopub.status.idle": "2024-12-22T00:37:03.144709Z",
|
||||
"shell.execute_reply": "2024-12-22T00:37:03.144175Z",
|
||||
"shell.execute_reply.started": "2024-12-22T00:37:03.115323Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -588,6 +795,112 @@
|
||||
" json.dump(dict1, fl, ensure_ascii=False) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a26a0a2b-c10e-4acf-bce9-902d16669b91",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"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_北体体质康健班202412.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20241220.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,45):\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[2]\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",
|
||||
"#print(dict1)\n",
|
||||
"for item in list1:\n",
|
||||
" #print(item)\n",
|
||||
" psy = []\n",
|
||||
" tcm = []\n",
|
||||
" spine = []\n",
|
||||
" for i in range(0,45):\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[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[5])\n",
|
||||
" #print(content)\n",
|
||||
" \n",
|
||||
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||||
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||||
" for k, v in 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[5]:\n",
|
||||
" \n",
|
||||
" dict1[k1]['psy'] = psy\n",
|
||||
" if 'tcm' in item[5]:\n",
|
||||
" \n",
|
||||
" dict1[k1]['tcm'] = tcm\n",
|
||||
" if 'spine' in item[5]:\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[6].replace('/','-').split(' ')[0]\n",
|
||||
"#print(dict1)\n",
|
||||
"filename = 'data/result_北体体质康健班202412-1.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",
|
||||
@@ -598,15 +911,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 50,
|
||||
"execution_count": 62,
|
||||
"id": "327c33e2-7437-4421-b70c-ec98234a5e88",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-22T07:18:54.900729Z",
|
||||
"iopub.status.busy": "2024-12-22T07:18:54.899962Z",
|
||||
"iopub.status.idle": "2024-12-22T07:19:29.111150Z",
|
||||
"shell.execute_reply": "2024-12-22T07:19:29.110336Z",
|
||||
"shell.execute_reply.started": "2024-12-22T07:18:54.900656Z"
|
||||
"iopub.execute_input": "2025-03-04T01:34:56.351921Z",
|
||||
"iopub.status.busy": "2025-03-04T01:34:56.351159Z",
|
||||
"iopub.status.idle": "2025-03-04T01:36:01.625317Z",
|
||||
"shell.execute_reply": "2025-03-04T01:36:01.624114Z",
|
||||
"shell.execute_reply.started": "2025-03-04T01:34:56.351849Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -614,7 +927,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"71\n"
|
||||
"116\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -627,11 +940,11 @@
|
||||
"headers = {\n",
|
||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||
" }\n",
|
||||
"filename = 'data/result_北体体质康健班202412-1.json'\n",
|
||||
"filename = 'data/result_陈庄检测人员-1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"file_path ='./北体体质康健班202412/'\n",
|
||||
"file_path ='./东营陈庄/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i=0\n",
|
||||
"list2 = []\n",
|
||||
@@ -641,7 +954,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",
|
||||
@@ -668,8 +981,9 @@
|
||||
" else:\n",
|
||||
" 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 or len(mydata['surveys']) >0:\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",
|
||||
@@ -681,24 +995,100 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "raw",
|
||||
"id": "640b2865-5739-464b-ac51-0ffc49adb00f",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
"cell_type": "code",
|
||||
"execution_count": 48,
|
||||
"id": "44a209a2-ca22-4a80-bbd9-37717347dfd5",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-03-03T06:41:43.203179Z",
|
||||
"iopub.status.busy": "2025-03-03T06:41:43.202419Z",
|
||||
"iopub.status.idle": "2025-03-03T06:41:43.225384Z",
|
||||
"shell.execute_reply": "2025-03-03T06:41:43.224812Z",
|
||||
"shell.execute_reply.started": "2025-03-03T06:41:43.203107Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"91\n",
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"headers = {\n",
|
||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||
" }\n",
|
||||
"filename = 'data/result_陈庄检测人员-1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"file_path ='./东营陈庄/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i=0\n",
|
||||
"list2 = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list1 = []\n",
|
||||
" mydata = {}\n",
|
||||
" \n",
|
||||
" id = str(k).rjust(4,\"0\")\n",
|
||||
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
|
||||
" mydata['title'] = '山东东营陈庄镇'\n",
|
||||
" mydata['subtitle'] = v['unit']\n",
|
||||
" mydata['id'] = id\n",
|
||||
" mydata['name'] = v['name']\n",
|
||||
" if v['sex'] == '男':\n",
|
||||
" mydata['gender'] = 'male'\n",
|
||||
" else:\n",
|
||||
" mydata['gender'] = 'female'\n",
|
||||
" \n",
|
||||
" mydata['month'] = v['month']\n",
|
||||
" mydata['fits'] = {}\n",
|
||||
" survey_list = ['tcm','psy_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",
|
||||
" if item in ['lung','pushup','step','situp']:\n",
|
||||
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
||||
" else:\n",
|
||||
" mark = v[item]['成绩'].split()[0]\n",
|
||||
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
|
||||
" #if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n",
|
||||
" #if len(mydata['fits']) >2 : \n",
|
||||
" if len(mydata['fits']) >2 or 'surveys' in mydata.keys():\n",
|
||||
" list2.append(mydata)\n",
|
||||
" \n",
|
||||
" i+=1\n",
|
||||
" #x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||||
" #print(id,v['name'],x.text)\n",
|
||||
" #print(mydata)\n",
|
||||
" #x.close()\n",
|
||||
"filename = 'data/data_陈庄检测人员.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(list2, fl, ensure_ascii=False)\n",
|
||||
"print(len(list2))\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 88,
|
||||
"execution_count": null,
|
||||
"id": "46ff1333-f051-4022-a765-e0964a2ee427",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-24T14:45:09.893552Z",
|
||||
"iopub.status.busy": "2024-12-24T14:45:09.892819Z",
|
||||
"iopub.status.idle": "2024-12-24T14:45:09.940625Z",
|
||||
"shell.execute_reply": "2024-12-24T14:45:09.940171Z",
|
||||
"shell.execute_reply.started": "2024-12-24T14:45:09.893481Z"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
|
||||
Reference in new issue
Block a user