{ "cells": [ { "cell_type": "markdown", "id": "1853a5ff-55c9-4c07-bc84-66e86b238fdc", "metadata": {}, "source": [ "## 人员基本信息导入" ] }, { "cell_type": "code", "execution_count": 1, "id": "d6449ec6-54af-4f68-8c32-69372e390acf", "metadata": { "execution": { "iopub.execute_input": "2025-09-22T03:30:37.564857Z", "iopub.status.busy": "2025-09-22T03:30:37.564250Z", "iopub.status.idle": "2025-09-22T03:30:37.781384Z", "shell.execute_reply": "2025-09-22T03:30:37.780531Z", "shell.execute_reply.started": "2025-09-22T03:30:37.564798Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "33 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, 1).value)\n", " person.setdefault(code, {})\n", " dict1 = {}\n", " dict1['name'] = sheet.cell(n, 2).value\n", " #dict1['sex'] = sheet.cell(n, 5).value\n", " dict1['unit'] = sheet.cell(n, 4).value \n", " dict1['birth'] = str(sheet.cell(n, 3).value).replace('/','-').split(' ')[0]\n", " dict1['phone'] = sheet.cell(n, 5).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),'ok')" ] }, { "cell_type": "markdown", "id": "7b114094-afdc-4776-8fb7-19ac05162e68", "metadata": {}, "source": [ "## 导入手工数据" ] }, { "cell_type": "code", "execution_count": 5, "id": "c24c957e-6cc5-4cab-81e2-cec86a7498c7", "metadata": { "execution": { "iopub.execute_input": "2025-09-22T03:48:21.444109Z", "iopub.status.busy": "2025-09-22T03:48:21.443422Z", "iopub.status.idle": "2025-09-22T03:48:21.472961Z", "shell.execute_reply": "2025-09-22T03:48:21.472454Z", "shell.execute_reply.started": "2025-09-22T03:48:21.444045Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "33\n" ] } ], "source": [ "import openpyxl\n", "import json\n", "import time\n", "from datetime import date\n", "\n", "wb = openpyxl.load_workbook('data/通用技术中国医药手工数据.xlsx',data_only=True)\n", "sheet = wb.active\n", "# sheets = wb.sheetnames\n", "\n", "filename = 'data/通用技术中国医药人员.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", "dict2 = {}\n", "\n", "for n in range(2, sheet.max_row+1):\n", " code = str(sheet.cell(n, 1).value)\n", " rq = date.fromisoformat('2025-09-18')\n", " birth = date.fromisoformat(dict1[code]['birth'].replace('/','-'))\n", " dict2[code] = dict1[code]\n", " days = (rq-birth).days\n", " dict2[code]['age'] = int(days/365)\n", " dict2[code]['month'] = int(days/365*12)\n", " dict2[code]['rq'] = '2025-09-18'\n", " if sheet.cell(n,4).value:\n", " dict2[code].setdefault('reaction',{})\n", " dict2[code]['reaction']['成绩'] = sheet.cell(n, 4).value\n", " if sheet.cell(n,5).value:\n", " dict2[code].setdefault('grip',{})\n", " dict2[code]['grip']['成绩'] = sheet.cell(n, 5).value\n", " if sheet.cell(n,7).value:\n", " dict2[code].setdefault('lung',{})\n", " dict2[code]['lung']['成绩'] = sheet.cell(n, 7).value\n", " if sheet.cell(n,6).value:\n", " dict2[code].setdefault('balance',{})\n", " dict2[code]['balance']['成绩'] = sheet.cell(n, 6).value\n", " if sheet.cell(n,3).value:\n", " dict2[code].setdefault('bmi',{})\n", " dict2[code]['bmi']['成绩'] = sheet.cell(n, 3).value\n", "\n", "\n", "filename = 'data/result_通用技术中国医药.json'\n", "with open(filename,'w') as fl:\n", " json.dump(dict2, fl, ensure_ascii=False) \n", "print(len(dict2))" ] }, { "cell_type": "markdown", "id": "57aedeb8-02e6-47d2-a54a-e803d441104a", "metadata": {}, "source": [ "## 生成测试得分" ] }, { "cell_type": "code", "execution_count": null, "id": "a64ad6b7-b1dd-42ca-9619-3adcb8e0674e", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "84ad4891-f424-417c-8818-c9544bff67ef", "metadata": {}, "source": [ "## 导入问卷信息(新)" ] }, { "cell_type": "code", "execution_count": 7, "id": "020be101-938b-427e-918d-faf2e74b5b7e", "metadata": { "execution": { "iopub.execute_input": "2025-09-22T03:57:31.502714Z", "iopub.status.busy": "2025-09-22T03:57:31.501987Z", "iopub.status.idle": "2025-09-22T03:57:31.516781Z", "shell.execute_reply": "2025-09-22T03:57:31.515780Z", "shell.execute_reply.started": "2025-09-22T03:57:31.502649Z" } }, "outputs": [], "source": [ "import json\n", "import csv\n", "import openpyxl\n", "import time\n", "from datetime import date\n", "\n", "\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[int(v['phone'])] = k\n", "\n", "list1 = []\n", "filename = 'data/survey_records_20250922.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", "nn = 0\n", "for item in list1:\n", " if int(item[3]) in phone.keys(): \n", " tcm = []\n", " code = phone[int(item[3])]\n", " \n", " for i in range(0,60):\n", " tcm.append(0)\n", " \n", " \n", " content = json.loads(item[4])\n", " if code not in dict1.keys():\n", " dict1[code] = dict3[code]\n", " rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n", " dict1[code]['rq'] = str(date.fromisoformat(item[5].replace('/','-').split(' ')[0]))\n", " #dict1[code]['rq'] = item[5].replace('/','-').split(' ')[0]\n", " else:\n", " rq=date.fromisoformat('2025-09-18')\n", " dict1[code]['rq'] = '2025-09-18'\n", " for k, v in content.items():\n", " \n", " if 'tcm' in k:\n", " i = int(k[3:])\n", " tcm[i-1] = int(v) \n", " \n", " if 'tcm' in item[4]: \n", " dict1[code]['tcm'] = tcm\n", " \n", " birth = date.fromisoformat(dict3[code]['birth'].replace('/','-'))\n", " \n", " days = (rq-birth).days \n", " dict1[code]['age'] = int(days/365)\n", " dict1[code]['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)" ] }, { "cell_type": "code", "execution_count": null, "id": "9560d0ca-4d39-400b-b054-214e243ca4e5", "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 }