{ "cells": [ { "cell_type": "markdown", "id": "f501bde1-90cb-40c4-9dd4-533c27f81be5", "metadata": {}, "source": [ "## 调查报告线下数据管理" ] }, { "cell_type": "markdown", "id": "ced4bf30-e7ea-4c4c-ae46-8720ffc07a76", "metadata": {}, "source": [ "## 羊庙人员信息导入" ] }, { "cell_type": "code", "execution_count": 109, "id": "9b2b755e-049e-48c5-87d3-dd37dceb59fe", "metadata": { "execution": { "iopub.execute_input": "2023-03-25T13:01:16.720629Z", "iopub.status.busy": "2023-03-25T13:01:16.720098Z", "iopub.status.idle": "2023-03-25T13:01:16.793226Z", "shell.execute_reply": "2023-03-25T13:01:16.791845Z", "shell.execute_reply.started": "2023-03-25T13:01:16.720582Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ok\n" ] } ], "source": [ "import json\n", "\n", "filename = 'data/羊庙测试人员信息.json'\n", "\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "dict2 = {}\n", "for k,v in dict1.items():\n", " for item in v:\n", " bh = item['avatar_id']\n", " del item['avatar_id']\n", " dict2[bh] = item\n", "filename = 'data/羊庙人员名单.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(dict2, fl, ensure_ascii=False,default=str)\n", "print('ok')" ] }, { "cell_type": "markdown", "id": "00e9f538-c0f5-46a0-b768-51480ad3fbaf", "metadata": {}, "source": [ "## 获取参加体测人员编号" ] }, { "cell_type": "code", "execution_count": 106, "id": "d89e0e5e-0782-40a3-bba3-862cc9865d4e", "metadata": { "execution": { "iopub.execute_input": "2023-03-25T12:53:20.720371Z", "iopub.status.busy": "2023-03-25T12:53:20.719832Z", "iopub.status.idle": "2023-03-25T12:53:20.755754Z", "shell.execute_reply": "2023-03-25T12:53:20.754239Z", "shell.execute_reply.started": "2023-03-25T12:53:20.720324Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "465\n" ] } ], "source": [ "import json\n", "import time\n", "import csv\n", "\n", "filename = '../item.json'\n", "item = {}\n", "unit = {}\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "for k,v in dict1.items():\n", " item[k] = v\n", "re_ta = {}\n", "dict1 = {}\n", "list1 = []\n", "#print(\"\\n运动项目信息:\")\n", "filename = 'data/140.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", "list2 = []\n", "for result in list1:\n", " user = int(result[2])\n", " if user not in list2:\n", " list2.append(user)\n", "list2.sort()\n", "print(len(list2))" ] }, { "cell_type": "markdown", "id": "2c48f588-135a-4d1a-b01e-96222b70b987", "metadata": {}, "source": [ "## 根据风险筛选统计卡获取信息" ] }, { "cell_type": "code", "execution_count": 110, "id": "e76837e8-cdf4-41e0-9d51-6ae5223de813", "metadata": { "execution": { "iopub.execute_input": "2023-03-25T13:01:26.806474Z", "iopub.status.busy": "2023-03-25T13:01:26.805933Z", "iopub.status.idle": "2023-03-25T13:01:26.931144Z", "shell.execute_reply": "2023-03-25T13:01:26.929813Z", "shell.execute_reply.started": "2023-03-25T13:01:26.806426Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "440\n", "ok\n" ] } ], "source": [ "import openpyxl\n", "import json\n", "import time\n", "\n", "wb = openpyxl.load_workbook('data/杨庙运动风险筛查统计表.xlsx')\n", "sheet = wb.active\n", "person = {}\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", " if sheet.cell(n, 8).value is not None:\n", " name = sheet.cell(n, 8).value\n", " else:\n", " name ='不详'\n", " dict1['name'] = name\n", " if sheet.cell(n, 9).value is not None:\n", " dict1['birth'] = str(sheet.cell(n, 9).value).split(' ')[0]\n", " if sheet.cell(n, 10).value is not None:\n", " dict1['phone'] = str(sheet.cell(n, 10).value)\n", " if sheet.cell(n,11).value is not None:\n", " dict1['id_num'] = sheet.cell(n,11).value\n", " person[code] = dict1\n", "print(len(person))\n", "filename = 'data/杨庙运动风险筛查统计表信息.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(person, fl, ensure_ascii=False,default=str)\n", "print('ok')" ] }, { "cell_type": "markdown", "id": "6cc6b614-85e2-43fd-bc97-301fc776fe29", "metadata": {}, "source": [ "## 根据恢复版获取信息" ] }, { "cell_type": "code", "execution_count": 111, "id": "1293cdaa-1fdf-43a5-99ce-a031a76f6688", "metadata": { "execution": { "iopub.execute_input": "2023-03-25T13:01:43.947501Z", "iopub.status.busy": "2023-03-25T13:01:43.946930Z", "iopub.status.idle": "2023-03-25T13:01:45.320648Z", "shell.execute_reply": "2023-03-25T13:01:45.319280Z", "shell.execute_reply.started": "2023-03-25T13:01:43.947454Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "350\n", "ok\n" ] } ], "source": [ "import openpyxl\n", "import json\n", "import time\n", "\n", "wb = openpyxl.load_workbook('data/羊庙恢复版.xlsx')\n", "sheet = wb.active\n", "person = {}\n", "for n in range(2, sheet.max_row+1):\n", " if sheet.cell(n, 4).value is not None: \n", " code = int(sheet.cell(n, 4).value)\n", " person.setdefault(code, {})\n", " dict1 = {}\n", " name = sheet.cell(n, 5).value\n", " dict1['name'] = name\n", " dict1['bh'] = n - 1\n", " dict1['sex'] = sheet.cell(n, 6).value\n", " if sheet.cell(n, 9).value is not None:\n", " dict1['phone'] = str(sheet.cell(n, 9).value)\n", " if sheet.cell(n,8).value is not None:\n", " dict1['id_num'] = sheet.cell(n,8).value\n", " if sheet.cell(n,3).value is not None:\n", " dict1['unit'] = sheet.cell(n,3).value\n", " person[code] = dict1\n", "print(len(person))\n", "filename = 'data/杨庙恢复版信息.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(person, fl, ensure_ascii=False,default=str)\n", "print('ok')" ] }, { "cell_type": "markdown", "id": "de1ce95b-4590-4eee-bd51-d37beabd6f87", "metadata": {}, "source": [ "## 风险筛选统计卡可用人员信息" ] }, { "cell_type": "code", "execution_count": 112, "id": "f21fff31-0da6-4c1a-bf7c-8c4a1d4a3ecf", "metadata": { "execution": { "iopub.execute_input": "2023-03-25T13:01:54.814448Z", "iopub.status.busy": "2023-03-25T13:01:54.813880Z", "iopub.status.idle": "2023-03-25T13:01:54.856798Z", "shell.execute_reply": "2023-03-25T13:01:54.855640Z", "shell.execute_reply.started": "2023-03-25T13:01:54.814400Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "103\n", "314\n", "555\n", "666\n", "777\n", "999\n", "1000\n", "1001\n", "2367\n", "3456\n", "6000\n", "6001\n", "6002\n", "6003\n", "6602\n", "8888\n", "8889\n", "9999\n", "10000\n", "11112\n", "66666\n", "77777\n", "88888\n", "98000\n", "99999\n", "111111\n", "888888\n", "999998\n", "999999\n", "9999999\n", "999999999\n" ] } ], "source": [ "re_ta = {}\n", "dict1 = {}\n", "list1 = []\n", "#print(\"\\n运动项目信息:\")\n", "filename = 'data/140.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", "list2 = []\n", "for result in list1:\n", " user = int(result[2])\n", " if user not in list2:\n", " list2.append(user)\n", "list2.sort()\n", "set1 = set()\n", "filename = 'data/杨庙恢复版信息.json'\n", "with open(filename,'r') as fl:\n", " dict_base = json.load(fl)\n", "for k, v in dict_base.items():\n", " set1.add(int(k))\n", "filename = 'data/杨庙运动风险筛查统计表信息.json'\n", "\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "list_fx = []\n", "\n", "for k,v in dict1.items():\n", " \n", " if int(k) in list2 and k not in dict_base.keys() and v['name'] != '不详': \n", " set1.add(int(k))\n", "#print(len(list_fx))\n", "#print(len(set1)) \n", "for item in list2:\n", " if item not in set1:\n", " print(item)" ] }, { "cell_type": "markdown", "id": "b08187a6-41d9-40ec-bc62-d99969148fe7", "metadata": {}, "source": [ "## 补充恢复版信息" ] }, { "cell_type": "code", "execution_count": 126, "id": "50a5e0f9-3850-48ac-9f3a-f5a7be51a7fd", "metadata": { "execution": { "iopub.execute_input": "2023-03-25T13:36:31.137236Z", "iopub.status.busy": "2023-03-25T13:36:31.136695Z", "iopub.status.idle": "2023-03-25T13:36:31.342725Z", "shell.execute_reply": "2023-03-25T13:36:31.341445Z", "shell.execute_reply.started": "2023-03-25T13:36:31.137189Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "438\n", "1 98776 唐庆振\n", "2 398 黄志全\n", "3 388 施怡如\n", "4 98767 张莉\n", "5 98766 张爱芹\n", "6 367 李树强\n", "7 339 刘俊英\n", "8 338 刘树训\n", "9 98765 张红霞\n", "10 314 不详\n", "11 313 王祝娥\n", "12 312 赵芝堂\n", "13 311 吕秀英\n", "14 308 刘玉娥\n", "15 307 程潍芳\n", "16 305 韩春光\n", "17 304 赵娥\n", "18 299 盖彦玮\n", "19 288 盖汝亭\n", "20 280 柯天新\n", "21 247 程华英\n", "22 246 郭俊敏\n", "23 244 罗桂贤\n", "24 235 胡巧英\n", "25 232 许义田\n", "26 230 韩红华\n", "27 226 杨秀荣\n", "28 223 樊风亭\n", "29 218 程玉良\n", "30 213 张金宗\n", "31 208 王小冬\n", "32 200 李勇军\n", "33 196 王连秀\n", "34 188 杨志敏\n", "35 151 许海仙\n", "36 149 盖梦娜\n", "37 148 冯静静\n", "38 147 王海方\n", "39 145 裴\n", "40 136 刘兆合\n", "41 134 张荣俊\n", "42 120 郑凤\n", "43 114 许建玲\n", "44 103 不详\n", "45 102 孙海莹\n", "46 99 周\n", "47 90 刘桂英\n", "48 89 石云贞\n", "49 80 刘凤英\n", "50 74 李若梅\n", "51 65 许秀凤\n", "52 64 刘小凤\n", "53 62 吕吉刚\n", "54 60 盖\n", "55 47 王其美\n", "56 38 罗炳顺\n", "57 35 藏学亮\n", "58 34 胡世杰\n", "59 29 盖叔臣\n", "60 21 黄雯青\n", "61 16 王金花\n", "62 14 石立华\n", "ok\n" ] } ], "source": [ "filename = 'data/杨庙恢复版信息.json'\n", "with open(filename,'r') as fl:\n", " dict_base = json.load(fl)\n", "for k, v in dict_base.items():\n", " set1.add(int(k))\n", "filename = 'data/杨庙运动风险筛查统计表信息.json'\n", "\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "for k,v in dict_base.items():\n", " if k in dict1.keys() and 'phone' not in v.keys() and 'phone' in dict1[k].keys():\n", " #print(k,v['name'])\n", " dict_base[k]['phone'] = dict1[k]['phone']\n", "\n", "for k, v in dict1.items():\n", " if int(k) in list2 and k not in dict_base.keys():\n", " dict_base[k] = v\n", " \n", "print(len(dict_base))\n", "#print(dict_base)\n", "filename = 'data/羊庙人员名单.json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl)\n", "i = 1\n", "for k, v in dict_base.items():\n", " if 'bh' not in v.keys():\n", " name = v['name']\n", " n = 0\n", " for k1,v1 in dict2.items():\n", " if name == v1['name']:\n", " bh = k1\n", " n = n+1\n", " if n ==1:\n", " dict_base[k]['bh'] = bh\n", " else:\n", " print(i,k,v['name'])\n", " i+=1\n", "filename = 'data/杨庙补充汇总信息.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(dict_base, fl, ensure_ascii=False,default=str)\n", "print('ok')" ] }, { "cell_type": "markdown", "id": "d31fa9b7-26d8-4101-94d1-f41723428aa9", "metadata": {}, "source": [ "## 成年问卷导入" ] }, { "cell_type": "code", "execution_count": null, "id": "dc20aabb-3942-49b9-8841-8e8a0823033a", "metadata": { "tags": [] }, "outputs": [], "source": [ "import openpyxl\n", "import json\n", "\n", "\n", "wb = openpyxl.load_workbook('data/羊庙问卷统计表(成年组).xlsx')\n", "sheet = wb.active\n", "# sheets = wb.sheetnames\n", "dict1 = {}\n", "dict3 = {}\n", "no_xinli = [108,389,268,270]\n", "sheet = wb.active\n", "data1 =list(sheet.values)\n", "list_bh = data1[0][1:]\n", "del data1[0]\n", "print(len(list_bh))\n", "for i in range(1,len(list_bh)+1):\n", " list2 = []\n", " \n", " for item in data1:\n", " list2.append(item[i])\n", " dict1[list_bh[i-1]] = list2\n", "for k, v in dict1.items():\n", " if 0 in v:\n", " print(k)\n" ] }, { "cell_type": "markdown", "id": "75dda87e-804e-42ba-b1a4-08c8a8b65050", "metadata": {}, "source": [ "## 老年问卷导入" ] }, { "cell_type": "code", "execution_count": null, "id": "09a354e6-a07a-40b8-9b8c-3499fb0b7c28", "metadata": { "tags": [] }, "outputs": [], "source": [ "import openpyxl\n", "import json\n", "\n", "\n", "wb = openpyxl.load_workbook('data/羊庙问卷统计表(老年组).xlsx')\n", "sheet = wb.active\n", "# sheets = wb.sheetnames\n", "dict1 = {}\n", "dict3 = {}\n", "no_xinli = [286]\n", "sheet = wb.active\n", "data1 =list(sheet.values)\n", "list_bh = data1[0][1:]\n", "print(list_bh)\n", "del data1[0]\n", "print(len(list_bh))\n", "for i in range(1,len(list_bh)+1):\n", " list2 = []\n", " \n", " for item in data1:\n", " list2.append(item[i])\n", " dict1[list_bh[i-1]] = list2\n", "for k, v in dict1.items():\n", " if 0 in v or ' ' in v:\n", " print(k)\n", "print(dict1)" ] }, { "cell_type": "markdown", "id": "3262d713-92a4-4790-81a3-976ff308ee3d", "metadata": {}, "source": [ "## 统计网络问卷信息" ] }, { "cell_type": "code", "execution_count": 119, "id": "08980670-fda9-4660-a619-2f5f5ed8d334", "metadata": { "execution": { "iopub.execute_input": "2023-03-25T13:14:20.914416Z", "iopub.status.busy": "2023-03-25T13:14:20.913887Z", "iopub.status.idle": "2023-03-25T13:14:20.939567Z", "shell.execute_reply": "2023-03-25T13:14:20.938206Z", "shell.execute_reply.started": "2023-03-25T13:14:20.914370Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "68\n", "68\n" ] } ], "source": [ "filename = 'data/merge1.json'\n", "\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "#print(dict1)\n", "filename = 'data/杨庙补充汇总信息.json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl)\n", "dict3 = {}\n", "for k, v in dict1.items():\n", " print(len(v))\n", " for item in v:\n", " phone = item['phone']\n", " dict3.setdefault(phone,{})\n", " #dict3[phone]['data'] = v['data']\n", " for k1,v1 in dict2.items():\n", " if 'phone' in v1.keys() and phone == v1['phone']:\n", " dict3[phone]['bh'] = k1\n", "print(len(dict3)) " ] }, { "cell_type": "code", "execution_count": null, "id": "f69677a3-57bb-43b0-9d62-38330d86bddd", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }