{ "cells": [ { "cell_type": "markdown", "id": "04524c85-988e-4dbf-86eb-939a9db7aa28", "metadata": {}, "source": [ "## 体测人员导入" ] }, { "cell_type": "code", "execution_count": 81, "id": "bbba6efc-73cd-4db6-bae7-014724fee731", "metadata": { "execution": { "iopub.execute_input": "2025-03-19T11:10:38.156756Z", "iopub.status.busy": "2025-03-19T11:10:38.156425Z", "iopub.status.idle": "2025-03-19T11:10:38.173971Z", "shell.execute_reply": "2025-03-19T11:10:38.173494Z", "shell.execute_reply.started": "2025-03-19T11:10:38.156730Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "37\n", "ok\n" ] } ], "source": [ "import openpyxl\n", "import json\n", "from datetime import date\n", "\n", "wb = openpyxl.load_workbook('data/2025级油田老年大学体质康健基础班.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'] = '2025级'\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", " 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/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": 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, "id": "a14eed8b-0f7f-44f6-9d99-ce7f48e0cf50", "metadata": { "execution": { "iopub.execute_input": "2025-03-19T11:40:25.979499Z", "iopub.status.busy": "2025-03-19T11:40:25.978815Z", "iopub.status.idle": "2025-03-19T11:40:26.001966Z", "shell.execute_reply": "2025-03-19T11:40:26.001013Z", "shell.execute_reply.started": "2025-03-19T11:40:25.979436Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "13\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", " 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", " 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": "code", "execution_count": 7, "id": "5a98acbe-5f00-4ee0-99b2-7ff8d0caa3bc", "metadata": { "execution": { "iopub.execute_input": "2025-04-07T09:45:18.579990Z", "iopub.status.busy": "2025-04-07T09:45:18.579417Z", "iopub.status.idle": "2025-04-07T09:45:18.655025Z", "shell.execute_reply": "2025-04-07T09:45:18.654445Z", "shell.execute_reply.started": "2025-04-07T09:45:18.579942Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "492\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", "metadata": {}, "source": [ "## 获取人员测试成绩" ] }, { "cell_type": "code", "execution_count": 89, "id": "970e171e-1360-448f-a28c-520ccb8f314a", "metadata": { "execution": { "iopub.execute_input": "2025-03-19T11:41:10.193763Z", "iopub.status.busy": "2025-03-19T11:41:10.193066Z", "iopub.status.idle": "2025-03-19T11:41:10.208195Z", "shell.execute_reply": "2025-03-19T11:41:10.207239Z", "shell.execute_reply.started": "2025-03-19T11:41:10.193698Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "13\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_20250319.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": "code", "execution_count": 20, "id": "e2526429-e779-4ec5-8a0e-bea623f54f29", "metadata": { "execution": { "iopub.execute_input": "2025-04-07T12:39:20.625284Z", "iopub.status.busy": "2025-04-07T12:39:20.624668Z", "iopub.status.idle": "2025-04-07T12:39:20.645248Z", "shell.execute_reply": "2025-04-07T12:39:20.644732Z", "shell.execute_reply.started": "2025-04-07T12:39:20.625230Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "57\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_20250326.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_陈庄检测人员-2.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": 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", "metadata": {}, "source": [ "## 生成测试得分" ] }, { "cell_type": "code", "execution_count": 26, "id": "c3b99428-00d5-45ea-9803-261194525fa4", "metadata": { "execution": { "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": [ { "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 = 'data/result_油田老年大学年度体质复测.json'\n", "with open(filename,'w') as fl:\n", " json.dump(dict2,fl , ensure_ascii=False) \n", "print('ok!') " ] }, { "cell_type": "markdown", "id": "d034a61d-1fbd-417b-99bd-277e43ebb678", "metadata": {}, "source": [ "## 导出测试人员信息" ] }, { "cell_type": "code", "execution_count": 75, "id": "0c60a509-dfc0-426a-a44e-e9a760139463", "metadata": { "execution": { "iopub.execute_input": "2025-03-14T08:10:25.874988Z", "iopub.status.busy": "2025-03-14T08:10:25.874253Z", "iopub.status.idle": "2025-03-14T08:10:25.912497Z", "shell.execute_reply": "2025-03-14T08:10:25.912021Z", "shell.execute_reply.started": "2025-03-14T08:10:25.874920Z" }, "tags": [] }, "outputs": [], "source": [ "import json\n", "import openpyxl\n", "\n", "items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n", "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "\n", "filename = 'data/result_东营市老年大学第三期体质班.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", "for k, v in dict1.items():\n", " list2 = []\n", " list2.append(str(k).rjust(5,'0'))\n", " list2.append(v['name']) \n", " list2.append(dict2[k]['sex'])\n", " list2.append(dict2[k]['unit'])\n", " if 'bmi' in v.keys():\n", " height = v['bmi']['成绩'].split(',')[0]\n", " weight = v['bmi']['成绩'].split(',')[1]\n", " list2.append(height)\n", " list2.append(weight)\n", " else:\n", " list2.append('')\n", " list2.append('')\n", " for item in items:\n", " if item in v.keys():\n", " list2.append(v[item]['成绩']) \n", " elif item =='name':\n", " list2.append(v[item])\n", " else:\n", " list2.append('')\n", " \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)" ] }, { "cell_type": "markdown", "id": "d794e69d-9444-4765-9b7d-8dcb0f8c4343", "metadata": {}, "source": [ "## 导入问卷信息" ] }, { "cell_type": "code", "execution_count": 91, "id": "891347c4-cd65-41f8-b5dd-b3ff3d1e249f", "metadata": { "execution": { "iopub.execute_input": "2025-03-19T11:41:43.991964Z", "iopub.status.busy": "2025-03-19T11:41:43.991276Z", "iopub.status.idle": "2025-03-19T11:41:44.009884Z", "shell.execute_reply": "2025-03-19T11:41:44.008939Z", "shell.execute_reply.started": "2025-03-19T11:41:43.991901Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "7\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_20250319.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)" ] }, { "cell_type": "markdown", "id": "9f9111f1-8cf0-4d45-b9b2-e3b631023581", "metadata": {}, "source": [ "## 获取问卷人员信息" ] }, { "cell_type": "code", "execution_count": null, "id": "d1d02189-e01a-4d7f-9fbb-09b5e72a38df", "metadata": { "tags": [] }, "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_东营老年大学.json'\n", "with open(filename,'r') as fl:\n", " dict3 = json.load(fl)\n", "\n", "\n", "list1 = []\n", "filename = 'data/Survey_20240321.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", "list2 = []\n", "for item in list1:\n", " list3 = []\n", " phone = item[2]\n", " content = json.loads(item[5])\n", " name = content['name']\n", " gender = content['gender']\n", " unit = content['unit']\n", " list2.append([name,phone,gender,unit])\n", "filename = 'data/东营老年大学问卷人员表.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "\n", "for row in list2:\n", " sheet.append(row)\n", " \n", "wb.save(filename)\n", "print('ok') " ] }, { "cell_type": "code", "execution_count": null, "id": "eb4091f4-9823-4361-acb2-f3e898f9524b", "metadata": { "tags": [] }, "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", " #for i in range(5,26):\n", " # new_valve = 5-psy[i]\n", " # psy[i] = new_valve\n", " for i in range(26,40):\n", " new_valve = 1+psy[i]\n", " psy[i] = new_valve\n", " psy[44] = []\n", " dict1[k1]['psy'] = psy\n", " if 'tcm' in item[5]:\n", " if tcm[40] ==0:\n", " tcm[40] =1\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": "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": "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", "metadata": {}, "source": [ "## 生成报告" ] }, { "cell_type": "code", "execution_count": 92, "id": "327c33e2-7437-4421-b70c-ec98234a5e88", "metadata": { "execution": { "iopub.execute_input": "2025-03-19T11:42:35.430535Z", "iopub.status.busy": "2025-03-19T11:42:35.429862Z", "iopub.status.idle": "2025-03-19T11:42:43.062551Z", "shell.execute_reply": "2025-03-19T11:42:43.062030Z", "shell.execute_reply.started": "2025-03-19T11:42:35.430472Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "13\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", " 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": 18, "id": "44a209a2-ca22-4a80-bbd9-37717347dfd5", "metadata": { "execution": { "iopub.execute_input": "2025-04-07T12:35:07.556776Z", "iopub.status.busy": "2025-04-07T12:35:07.556176Z", "iopub.status.idle": "2025-04-07T12:35:08.133474Z", "shell.execute_reply": "2025-04-07T12:35:08.132966Z", "shell.execute_reply.started": "2025-04-07T12:35:07.556719Z" } }, "outputs": [], "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_陈庄检测人员-3.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "list1 = []\n", "file_path ='./东营陈庄3/'\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", " \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" ] }, { "cell_type": "code", "execution_count": 36, "id": "7ee80847-2bc0-4cbe-9534-c5dcf97c2833", "metadata": { "execution": { "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": [ { "name": "stdout", "output_type": "stream", "text": [ "12\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_油田老年大学年度体质复测.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", " 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": "46ff1333-f051-4022-a765-e0964a2ee427", "metadata": {}, "outputs": [], "source": [ "import json\n", "import csv\n", "import openpyxl\n", "import time\n", "from datetime import date\n", "import ast\n", "\n", "items = ['lung','grip','flexion','balance','reaction','step']\n", "title = ['编号','姓名','性别','年龄','单位','身高','体重','得分','肺活量','得分','握力','得分','坐位体前屈','得分','单脚站立','得分','选择反应时','得分','台阶指数','得分']\n", "filename = 'data/北体体质康健班202412.json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl)\n", "\n", "filename = 'data/data2.json'\n", "with open(filename,'r') as fl:\n", " list1 = json.load(fl)\n", "list2 = []\n", "for item in list1:\n", " list3 = []\n", " code = item['id']\n", " if 'fits' in item.keys() or 'surveysScore' in item.keys():\n", " list3.append(code)\n", " list3.append(dict2[code]['name'])\n", " list3.append(dict2[code]['sex'])\n", " list3.append(dict2[code]['age'])\n", " list3.append(dict2[code]['unit'])\n", " \n", " if 'fits' in item.keys():\n", " v = item['fits']\n", " if 'bmi' in v.keys():\n", " height = v['bmi']['mark'].split(',')[0]\n", " weight = v['bmi']['mark'].split(',')[1]\n", " list3.append(height)\n", " list3.append(weight)\n", " list3.append(v['bmi']['score']) \n", " else:\n", " list3.append('')\n", " list3.append('')\n", " list3.append('')\n", " for xm in items:\n", " if xm in v.keys():\n", " list3.append(v[xm]['mark'])\n", " list3.append(v[xm]['score']) \n", " else:\n", " list3.append('')\n", " list3.append('')\n", " else:\n", " for i in range(0,15):\n", " list3.append('')\n", " if 'surveysScore' in item.keys():\n", " v = item['surveysScore']\n", " list3.append(v['tcm']['type']['name'])\n", " list3.append(v['tcm']['near'])\n", " list3.append(v['psy']['身体健康满意度'])\n", " list3.append(v['psy']['心理健康'])\n", " list3.append(v['psy']['社会支持'])\n", " list3.append(v['psy']['环境满意度'])\n", " list3.append(v['spine']['颈椎段'])\n", " list3.append(v['spine']['胸椎段'])\n", " list3.append(v['spine']['腰椎段'])\n", " list3.append(v['spine']['骶尾椎段'])\n", " else:\n", " for i in range(0,10):\n", " list3.append('')\n", " list2.append(list3) \n", " \n", "filename = 'data/北体体质康健班体测情况表202412.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, "id": "9ce2589b-881a-4c36-8a48-9cfd212cc40b", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }