20251222
This commit is contained in:
1 parent
6803e6fff6
commit
b894e793a5
5 files changed
+1705
-202
No files matched your search
+662
-26
@@ -42,6 +42,53 @@
|
||||
"print(len(person),'ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 50,
|
||||
"id": "4b8567fe-1d70-4361-9fda-6180033843ea",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-19T13:00:53.324989Z",
|
||||
"iopub.status.busy": "2025-12-19T13:00:53.324102Z",
|
||||
"iopub.status.idle": "2025-12-19T13:00:53.345891Z",
|
||||
"shell.execute_reply": "2025-12-19T13:00:53.345160Z",
|
||||
"shell.execute_reply.started": "2025-12-19T13:00:53.324915Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1 ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/南化合作者.xlsx',data_only=True)\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, 2).value)\n",
|
||||
" person.setdefault(code, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 1).value\n",
|
||||
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
||||
" dict1['unit'] = ''\n",
|
||||
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\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),'ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "048a95aa-1691-45f6-b933-6eaf95ae1d30",
|
||||
@@ -90,11 +137,51 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
||||
"execution_count": 51,
|
||||
"id": "b5676c48-cbc2-49d5-a87d-bb4fba4c27fa",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-19T13:01:09.505132Z",
|
||||
"iopub.status.busy": "2025-12-19T13:01:09.504235Z",
|
||||
"iopub.status.idle": "2025-12-19T13:01:09.517218Z",
|
||||
"shell.execute_reply": "2025-12-19T13:01:09.515931Z",
|
||||
"shell.execute_reply.started": "2025-12-19T13:01:09.505045Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import datetime\n",
|
||||
"import csv\n",
|
||||
"from datetime import date\n",
|
||||
"import my_module as My\n",
|
||||
"\n",
|
||||
"filename = 'data/南京化工人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"filename = 'data/marks_20251219-1.csv'\n",
|
||||
"re_ta = My.get_result(filename,dict1)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/result_南京化工(2512).json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "4d77a1bf-74fa-4836-95bc-b52311e26ea2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
@@ -106,11 +193,11 @@
|
||||
"filename = 'data/南京化工人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"filename = 'data/marks_20250703.csv'\n",
|
||||
"filename = 'data/marks_20251219-1.csv'\n",
|
||||
"re_ta = My.get_result(filename,dict1)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/result_南京化工.json'\n",
|
||||
"filename = 'data/result_南京化工(2512).json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
@@ -126,10 +213,26 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 52,
|
||||
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-19T13:01:55.523463Z",
|
||||
"iopub.status.busy": "2025-12-19T13:01:55.522900Z",
|
||||
"iopub.status.idle": "2025-12-19T13:01:55.535201Z",
|
||||
"shell.execute_reply": "2025-12-19T13:01:55.533872Z",
|
||||
"shell.execute_reply.started": "2025-12-19T13:01:55.523413Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
@@ -137,7 +240,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_南京化工.json'\n",
|
||||
"filename = 'data/result_南京化工(2512).json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"for k, v in dict2.items():\n",
|
||||
@@ -160,7 +263,65 @@
|
||||
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
|
||||
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||||
"\n",
|
||||
"filename = f'data/result_南京化工.json'\n",
|
||||
"filename = f'data/result_南京化工(2512).json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||
"print('ok!') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 49,
|
||||
"id": "15c8a68c-86ce-441e-99c2-5fc803003ffd",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-19T13:00:15.836697Z",
|
||||
"iopub.status.busy": "2025-12-19T13:00:15.835734Z",
|
||||
"iopub.status.idle": "2025-12-19T13:00:15.844310Z",
|
||||
"shell.execute_reply": "2025-12-19T13:00:15.843424Z",
|
||||
"shell.execute_reply.started": "2025-12-19T13:00:15.836643Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
"import my_module as My\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_南京合作者.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 'bmi' in v.keys():\n",
|
||||
" #bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
|
||||
" bmi_data = v['bmi']['成绩']\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'] = My.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'] = My.cal_score(data1)\n",
|
||||
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||||
"\n",
|
||||
"filename = f'data/result_南京合作者.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||
"print('ok!') "
|
||||
@@ -231,6 +392,59 @@
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6a09d6b0-537f-49e8-b9c7-acfd95d9d8b6",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导出未参加测试人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"id": "ac8d363e-862b-4155-a966-3ab15d2da336",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-17T09:28:53.660937Z",
|
||||
"iopub.status.busy": "2025-12-17T09:28:53.659835Z",
|
||||
"iopub.status.idle": "2025-12-17T09:28:53.683257Z",
|
||||
"shell.execute_reply": "2025-12-17T09:28:53.682805Z",
|
||||
"shell.execute_reply.started": "2025-12-17T09:28:53.660879Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"filename = 'data/result_南京化工(2512).json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/南京化工人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"\n",
|
||||
"i = 1\n",
|
||||
"for k, v in dict2.items(): \n",
|
||||
" if k not in dict1.keys():\n",
|
||||
" list2 = [i,k,v['name'],v['unit'],v['phone']]\n",
|
||||
" i+=1\n",
|
||||
" list1.append(list2)\n",
|
||||
"#print(list1)\n",
|
||||
"filename = f'data/南京化工未测试人员名单(截至20251217).xlsx'\n",
|
||||
"title = ['序号','员工编号','姓名','部门','手机号码']\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
"for row in list1:\n",
|
||||
" sheet.append(row) \n",
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
|
||||
@@ -295,6 +509,192 @@
|
||||
"wb.save(filename) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"id": "becf7708-1122-4d46-84f2-a790646b3c08",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-17T09:17:14.884858Z",
|
||||
"iopub.status.busy": "2025-12-17T09:17:14.883621Z",
|
||||
"iopub.status.idle": "2025-12-17T09:17:14.906561Z",
|
||||
"shell.execute_reply": "2025-12-17T09:17:14.906028Z",
|
||||
"shell.execute_reply.started": "2025-12-17T09:17:14.884762Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/南京化工人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone = {}\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone[str(v['phone'])] = k\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251219-1.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",
|
||||
"i =1\n",
|
||||
"list2 = []\n",
|
||||
"for item in list1:\n",
|
||||
" content = json.loads(json.loads(item[1]))\n",
|
||||
" phone_num = str(item[0])[2:]\n",
|
||||
" if phone_num in phone:\n",
|
||||
" content = json.loads(json.loads(item[1]))\n",
|
||||
" list3 = []\n",
|
||||
" list3.append(content['code'])\n",
|
||||
" list3.append(content['name'])\n",
|
||||
" list3.append(content['gender'])\n",
|
||||
" list2.append(list3)\n",
|
||||
"filename = 'data/南化问卷情况表(202512).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"#sheet.append(title)\n",
|
||||
"for row in list2:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0e36111a-cdd2-4306-92af-d5d062b0b678",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计未参加问卷人员情况"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"id": "e6e77dac-68a1-4495-b86d-6c0179ca4641",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-17T09:16:37.963798Z",
|
||||
"iopub.status.busy": "2025-12-17T09:16:37.962781Z",
|
||||
"iopub.status.idle": "2025-12-17T09:16:37.989342Z",
|
||||
"shell.execute_reply": "2025-12-17T09:16:37.988840Z",
|
||||
"shell.execute_reply.started": "2025-12-17T09:16:37.963744Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/南京化工人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone = {}\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone[str(v['phone'])] = k\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251217.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",
|
||||
"list2 = []\n",
|
||||
"for item in list1:\n",
|
||||
" phone_num = str(item[0])[2:]\n",
|
||||
" if phone_num in phone.keys():\n",
|
||||
" code = phone[phone_num]\n",
|
||||
" list3 = []\n",
|
||||
" list3.append(code)\n",
|
||||
" list3.append(content['code'])\n",
|
||||
" list3.append(dict1[code]['name'])\n",
|
||||
" list3.append(dict1[code]['sex'])\n",
|
||||
" list3.append(dict1[code]['unit'])\n",
|
||||
" list3.append(phone_num)\n",
|
||||
" list2.append(list3)\n",
|
||||
"filename = 'data/南化未参加问卷人员情况表(202512).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"#sheet.append(title)\n",
|
||||
"for row in list2:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"id": "676c8816-28eb-4914-97c1-bc0a3c7896e7",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-17T09:26:57.896010Z",
|
||||
"iopub.status.busy": "2025-12-17T09:26:57.895164Z",
|
||||
"iopub.status.idle": "2025-12-17T09:26:57.919497Z",
|
||||
"shell.execute_reply": "2025-12-17T09:26:57.918911Z",
|
||||
"shell.execute_reply.started": "2025-12-17T09:26:57.895933Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/南京化工人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone = set()\n",
|
||||
"\n",
|
||||
"filename = 'data/sql_20251217.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",
|
||||
"list2 = []\n",
|
||||
"for item in list1:\n",
|
||||
" phone_num = str(item[0])[2:]\n",
|
||||
" phone.add(phone_num)\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" if str(v['phone']) not in phone:\n",
|
||||
" \n",
|
||||
" list3 = []\n",
|
||||
" list3.append(k)\n",
|
||||
" list3.append(v['name'])\n",
|
||||
" list3.append(v['sex'])\n",
|
||||
" list3.append(v['unit'])\n",
|
||||
" list3.append(v['phone'])\n",
|
||||
" list2.append(list3)\n",
|
||||
"filename = 'data/南化未参加问卷人员情况表(202512).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"#sheet.append(title)\n",
|
||||
"for row in list2:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -588,11 +988,35 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7392d5bf-c6a8-4cdf-8653-0fb4961f1405",
|
||||
"cell_type": "markdown",
|
||||
"id": "72f1a3a9-ae54-4e6f-ab7f-a06771c42b28",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"## 导入问卷信息(20251219)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"id": "235939f8-6072-4f72-8e83-bcbdd911125f",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-19T12:28:44.188661Z",
|
||||
"iopub.status.busy": "2025-12-19T12:28:44.188060Z",
|
||||
"iopub.status.idle": "2025-12-19T12:28:44.219189Z",
|
||||
"shell.execute_reply": "2025-12-19T12:28:44.218579Z",
|
||||
"shell.execute_reply.started": "2025-12-19T12:28:44.188607Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"78\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
@@ -601,21 +1025,60 @@
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"dict1 = {}\n",
|
||||
"filename = f'data/南京化工人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = f'data/result_南京化工(2512).json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251027.csv'\n",
|
||||
"filename = 'data/sql_20251219-1.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",
|
||||
"nn = 0\n",
|
||||
"nn = 1\n",
|
||||
"i =1\n",
|
||||
"dict4 = {}\n",
|
||||
"for item in list1:\n",
|
||||
" dict2 = {}\n",
|
||||
" \n",
|
||||
" phone = str(item[0])[2:]\n",
|
||||
" content = json.loads(item[1])\n",
|
||||
" print(type(json.loads(content)))"
|
||||
" content = json.loads(json.loads(item[1]))\n",
|
||||
" tcm = []\n",
|
||||
" for i in range(0,60):\n",
|
||||
" tcm.append(0)\n",
|
||||
" for k, v in content.items(): \n",
|
||||
" if 'tcm' not in k:\n",
|
||||
" dict2[k] = v\n",
|
||||
" else:\n",
|
||||
" i = int(k[3:])\n",
|
||||
" tcm[i-1] = int(v)\n",
|
||||
" \n",
|
||||
" code = str(int(dict2['code']))\n",
|
||||
" if code in dict3.keys():\n",
|
||||
" dict3[code]['waist'] = dict2['waist']\n",
|
||||
" dict3[code]['hip'] = dict2['hip']\n",
|
||||
" dict3[code]['tcm'] = tcm\n",
|
||||
" elif code in dict1.keys():\n",
|
||||
" dict3[code] = dict1[code]\n",
|
||||
" birth = date.fromisoformat(dict3[code]['birth'].replace('/','-'))\n",
|
||||
" rq = date.fromisoformat(item[2].replace('/','-').split(' ')[0])\n",
|
||||
" days = (rq-birth).days \n",
|
||||
" dict3[code]['age'] = int(days/365)\n",
|
||||
" dict3[code]['month'] = int(days/365*12)\n",
|
||||
" \n",
|
||||
" dict3[code]['waist'] = dict2['waist']\n",
|
||||
" dict3[code]['hip'] = dict2['hip']\n",
|
||||
" dict3[code]['tcm'] = tcm\n",
|
||||
" \n",
|
||||
"filename = 'data/result_南京化工(2512)-1.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
||||
"print(len(dict3))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -671,15 +1134,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": 40,
|
||||
"id": "e233e6c3-9c3f-42c7-8057-012bbcfe8b26",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-10-28T02:58:52.451889Z",
|
||||
"iopub.status.busy": "2025-10-28T02:58:52.451452Z",
|
||||
"iopub.status.idle": "2025-10-28T02:58:52.546239Z",
|
||||
"shell.execute_reply": "2025-10-28T02:58:52.545487Z",
|
||||
"shell.execute_reply.started": "2025-10-28T02:58:52.451850Z"
|
||||
"iopub.execute_input": "2025-12-19T12:21:00.570832Z",
|
||||
"iopub.status.busy": "2025-12-19T12:21:00.570241Z",
|
||||
"iopub.status.idle": "2025-12-19T12:21:00.617789Z",
|
||||
"shell.execute_reply": "2025-12-19T12:21:00.617186Z",
|
||||
"shell.execute_reply.started": "2025-12-19T12:21:00.570776Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -1306,8 +1769,181 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 47,
|
||||
"id": "1b9d4042-5e73-44e3-8079-eee2c5be1858",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-19T12:34:33.579089Z",
|
||||
"iopub.status.busy": "2025-12-19T12:34:33.578712Z",
|
||||
"iopub.status.idle": "2025-12-19T12:34:33.629552Z",
|
||||
"shell.execute_reply": "2025-12-19T12:34:33.629034Z",
|
||||
"shell.execute_reply.started": "2025-12-19T12:34:33.579053Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||
"filename = 'data/result_南京化工(2512)-1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"data_list = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list6 = []\n",
|
||||
" list6.append(str(k).rjust(4,'0'))\n",
|
||||
" list6.append(v['name'])\n",
|
||||
" list6.append(v['sex'])\n",
|
||||
" list6.append(v['unit'])\n",
|
||||
" list6.append(v['age'])\n",
|
||||
" if 'bmi' in v.keys():\n",
|
||||
" bmi = v['bmi']['成绩']\n",
|
||||
" list6.append(bmi.split(',')[0]+' 厘米')\n",
|
||||
" list6.append(bmi.split(',')[1]+' 千克')\n",
|
||||
" list6.append(v['bmi']['score'])\n",
|
||||
" else:\n",
|
||||
" list6.append('')\n",
|
||||
" list6.append('')\n",
|
||||
" list6.append('')\n",
|
||||
" for xm in list_item:\n",
|
||||
" if xm in v.keys():\n",
|
||||
" list6.append(v[xm]['成绩'])\n",
|
||||
" list6.append(v[xm]['score'])\n",
|
||||
" else:\n",
|
||||
" list6.append('')\n",
|
||||
" list6.append('')\n",
|
||||
" if 'waist' in v.keys():\n",
|
||||
" list6.append(v['waist'])\n",
|
||||
" else:\n",
|
||||
" list6.append('')\n",
|
||||
" if 'hip' in v.keys():\n",
|
||||
" list6.append(v['hip'])\n",
|
||||
" else:\n",
|
||||
" list6.append('')\n",
|
||||
" if 'tcm' in v.keys():\n",
|
||||
" list1 = []\n",
|
||||
" tcm =v['tcm']\n",
|
||||
" for item in tcm:\n",
|
||||
" list1.append(item)\n",
|
||||
" score = tcm_calc(list1)\n",
|
||||
"\n",
|
||||
" result = tcm_kind(score)\n",
|
||||
" kind = result['kind']\n",
|
||||
" near = result['near']\n",
|
||||
" #print(k,kinds[kind], near, score)\n",
|
||||
" list6.append(kinds[kind])\n",
|
||||
" if near:\n",
|
||||
" list6.append('是')\n",
|
||||
" else:\n",
|
||||
" list6.append('')\n",
|
||||
" for item in score:\n",
|
||||
" list6.append(item)\n",
|
||||
" else:\n",
|
||||
" for i in range(0,11):\n",
|
||||
" list6.append('')\n",
|
||||
" i+=1\n",
|
||||
" \n",
|
||||
" data_list.append(list6)\n",
|
||||
"filename = 'data/南京化工(2512).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '身高', '体重', 'bmi', '肺活量', '得分', '握力', '得分', '坐位体前屈', '得分', '纵跳', '得分', '俯卧撑', '得分', '单脚站立', '得分', '选择反应时', '得分', '台阶指数', '得分', '一分钟仰卧起坐', '得分','腰围','臀围','中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀']\n",
|
||||
"sheet.append(title)\n",
|
||||
"for row in data_list:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 56,
|
||||
"id": "7e3a34a5-5e00-4594-b78f-c8529c5eccfd",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-12-19T13:06:03.574275Z",
|
||||
"iopub.status.busy": "2025-12-19T13:06:03.573467Z",
|
||||
"iopub.status.idle": "2025-12-19T13:06:47.044868Z",
|
||||
"shell.execute_reply": "2025-12-19T13:06:47.043893Z",
|
||||
"shell.execute_reply.started": "2025-12-19T13:06:03.574203Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"78\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_南京化工(2512)-1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"file_path ='./南京化工(202512)/'\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(8,\"0\")\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','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",
|
||||
" list1.append(mydata)\n",
|
||||
" list2.append([k,v['name']])\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",
|
||||
"print(i)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "02b19f4d-466d-4370-8638-17b02159c28d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user