This commit is contained in:
512song committed 2025-10-30 08:24:56 +08:00
1 parent a10492f0ad
commit 9ec7907bde
4 files changed
+1062 -1793

No files matched your search

+187 -82
View File
@@ -10,48 +10,33 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-21T02:05:09.966940Z",
"iopub.status.busy": "2025-10-21T02:05:09.966195Z",
"iopub.status.idle": "2025-10-21T02:05:10.249499Z",
"shell.execute_reply": "2025-10-21T02:05:10.248277Z",
"shell.execute_reply.started": "2025-10-21T02:05:09.966870Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"270 ok\n"
]
}
],
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/胜利采油厂人员名单.xlsx',data_only=True)\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",
" code = int(sheet.cell(n, 4).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 4).value\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 5).value\n",
" dict1['unit'] = sheet.cell(n, 3).value \n",
" dict1['unit'] = sheet.cell(n, 2).value \n",
" dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0]\n",
" #dict1['phone'] = sheet.cell(n, 12).value \n",
" dict1['phone'] = sheet.cell(n, 12).value \n",
" person[code] = dict1\n",
"filename = 'data/胜利采油厂人员.json'\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person),'ok')"
@@ -67,31 +52,16 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "ce406710-6b7d-4c51-98ec-78883bd3ce5f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-21T02:05:49.362922Z",
"iopub.status.busy": "2025-10-21T02:05:49.362143Z",
"iopub.status.idle": "2025-10-21T02:05:49.376741Z",
"shell.execute_reply": "2025-10-21T02:05:49.375761Z",
"shell.execute_reply.started": "2025-10-21T02:05:49.362862Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"\n",
"filename = 'data/胜利采油厂人员.json'\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -105,7 +75,7 @@
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
"\n",
"# 将 json 数据写入文件\n",
"with open(\"data/data_胜利采油厂人员.json\", \"w\",encoding = 'utf-8') as file:\n",
"with open(\"data/data_南京化工人员.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print('ok')"
]
@@ -465,26 +435,10 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"id": "9b801085-ca98-4958-8dcc-bcd9985fcd4b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-09-01T07:20:37.177771Z",
"iopub.status.busy": "2025-09-01T07:20:37.177055Z",
"iopub.status.idle": "2025-09-01T07:20:37.198841Z",
"shell.execute_reply": "2025-09-01T07:20:37.198253Z",
"shell.execute_reply.started": "2025-09-01T07:20:37.177707Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"83\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
@@ -550,6 +504,120 @@
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "acfc1736-9185-4217-bd05-a83b7e292725",
"metadata": {},
"source": [
"## 导入问卷信息(20251027)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "4b6cf9bc-fe84-4cf6-b762-8c30f8dd7953",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-28T02:58:31.746734Z",
"iopub.status.busy": "2025-10-28T02:58:31.746060Z",
"iopub.status.idle": "2025-10-28T02:58:31.786856Z",
"shell.execute_reply": "2025-10-28T02:58:31.786112Z",
"shell.execute_reply.started": "2025-10-28T02:58:31.746685Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"81\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/sql_20251028.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",
"for item in list1:\n",
" dict2 = {}\n",
" \n",
" phone = str(item[0])[2:]\n",
" 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 = dict2['code']\n",
" dict1.setdefault(code,{})\n",
" dict1[code]['name'] = dict2['name']\n",
" if dict2['gender'] == 'male':\n",
" dict1[code]['sex'] = '男'\n",
" else:\n",
" dict1[code]['sex'] = '女'\n",
" dict1[code]['birth'] = str(dict2['birth'])+'-01'\n",
" dict1[code]['unit'] = '南京化工'\n",
" dict1[code]['phone'] = phone\n",
" dict1[code]['weight'] = dict2['weight']\n",
" dict1[code]['waist'] = dict2['waist']\n",
" dict1[code]['hip'] = dict2['hip']\n",
" dict1[code]['tcm'] = tcm\n",
"filename = 'data/result_南京化工-3.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7392d5bf-c6a8-4cdf-8653-0fb4961f1405",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/sql_20251027.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",
"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)))"
]
},
{
"cell_type": "markdown",
"id": "89689b86-3fae-402e-a456-a646f0c7201f",
@@ -603,10 +671,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"id": "e233e6c3-9c3f-42c7-8057-012bbcfe8b26",
"metadata": {},
"outputs": [],
"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"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
@@ -721,7 +805,7 @@
" }\n",
"\n",
"\n",
"filename = 'data/result_南京化工-2.json'\n",
"filename = 'data/result_南京化工-3.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"i = 1\n",
@@ -743,16 +827,17 @@
" list3.append(k)\n",
" list3.append(v['name'])\n",
" list3.append(v['sex'])\n",
" list3.append(v['phone'])\n",
" list3.append(v['weight'])\n",
" list3.append(v['yao'])\n",
" list3.append(v['tun'])\n",
" list3.append(v['waist'])\n",
" list3.append(v['hip'])\n",
" list3.append(kinds[kind])\n",
" list3.append(near)\n",
" for item in score:\n",
" list3.append(item)\n",
" list2.append(list3)\n",
"\n",
"filename = 'data/南化第二次问卷明细表(截至20250831).xlsx'\n",
"filename = 'data/南化第三次问卷明细表(截至20251028).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"\n",
@@ -863,10 +948,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"id": "23ffd115-72a3-4f90-9e64-ffa6420df8a4",
"metadata": {},
"outputs": [],
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-27T06:11:24.661422Z",
"iopub.status.busy": "2025-10-27T06:11:24.660908Z",
"iopub.status.idle": "2025-10-27T06:11:24.977141Z",
"shell.execute_reply": "2025-10-27T06:11:24.975637Z",
"shell.execute_reply.started": "2025-10-27T06:11:24.661386Z"
}
},
"outputs": [
{
"ename": "KeyError",
"evalue": "'month'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[18], line 32\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 30\u001b[0m mydata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgender\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfemale\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m---> 32\u001b[0m mydata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmonth\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[43mv\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mmonth\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[1;32m 33\u001b[0m mydata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfits\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m {}\n\u001b[1;32m 34\u001b[0m survey_list \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtcm\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpsy57\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mspine\u001b[39m\u001b[38;5;124m'\u001b[39m]\n",
"\u001b[0;31mKeyError\u001b[0m: 'month'"
]
}
],
"source": [
"import requests\n",
"import json\n",
@@ -876,11 +981,11 @@
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_南京化工-2.json'\n",
"filename = 'data/result_南京化工-3.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./南京化工第二批问卷/'\n",
"file_path ='./南京化工第三批问卷(251021)/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"list2 = []\n",
@@ -939,15 +1044,15 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"id": "fc2bfab2-7f56-4abf-b2c4-0fb49a0da563",
"metadata": {
"execution": {
"iopub.execute_input": "2025-09-01T07:20:49.606201Z",
"iopub.status.busy": "2025-09-01T07:20:49.605939Z",
"iopub.status.idle": "2025-09-01T07:21:08.746449Z",
"shell.execute_reply": "2025-09-01T07:21:08.745281Z",
"shell.execute_reply.started": "2025-09-01T07:20:49.606179Z"
"iopub.execute_input": "2025-10-27T06:12:04.742517Z",
"iopub.status.busy": "2025-10-27T06:12:04.738837Z",
"iopub.status.idle": "2025-10-27T06:12:30.134155Z",
"shell.execute_reply": "2025-10-27T06:12:30.133408Z",
"shell.execute_reply.started": "2025-10-27T06:12:04.742463Z"
}
},
"outputs": [
@@ -955,7 +1060,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"83\n"
"72\n"
]
}
],
@@ -968,11 +1073,11 @@
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_南京化工-2.json'\n",
"filename = 'data/result_南京化工-3.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./南京化工第二批问卷/'\n",
"file_path ='./南京化工第三批问卷/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"list2 = []\n",