{ "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": 1, "id": "9b2b755e-049e-48c5-87d3-dd37dceb59fe", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T02:34:03.703925Z", "iopub.status.busy": "2023-03-26T02:34:03.702992Z", "iopub.status.idle": "2023-03-26T02:34:03.796862Z", "shell.execute_reply": "2023-03-26T02:34:03.795940Z", "shell.execute_reply.started": "2023-03-26T02:34:03.703874Z" }, "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": 23, "id": "d89e0e5e-0782-40a3-bba3-862cc9865d4e", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T05:26:42.561868Z", "iopub.status.busy": "2023-03-26T05:26:42.561418Z", "iopub.status.idle": "2023-03-26T05:26:42.586792Z", "shell.execute_reply": "2023-03-26T05:26:42.585901Z", "shell.execute_reply.started": "2023-03-26T05:26:42.561837Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "465\n", "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 177, 178, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 342, 343, 344, 345, 346, 347, 348, 349, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 555, 666, 777, 999, 1000, 1001, 2367, 3456, 6000, 6001, 6002, 6003, 6602, 8888, 8889, 9999, 10000, 11112, 66666, 77777, 88888, 98000, 98765, 98766, 98767, 98776, 99999, 111111, 888888, 999998, 999999, 9999999, 999999999]\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))\n", "print(list2)" ] }, { "cell_type": "markdown", "id": "2c48f588-135a-4d1a-b01e-96222b70b987", "metadata": {}, "source": [ "## 根据风险筛选统计卡获取信息" ] }, { "cell_type": "code", "execution_count": 3, "id": "e76837e8-cdf4-41e0-9d51-6ae5223de813", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T02:34:31.526348Z", "iopub.status.busy": "2023-03-26T02:34:31.525499Z", "iopub.status.idle": "2023-03-26T02:34:31.761154Z", "shell.execute_reply": "2023-03-26T02:34:31.760402Z", "shell.execute_reply.started": "2023-03-26T02:34:31.526306Z" }, "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": 4, "id": "1293cdaa-1fdf-43a5-99ce-a031a76f6688", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T02:35:05.771818Z", "iopub.status.busy": "2023-03-26T02:35:05.770889Z", "iopub.status.idle": "2023-03-26T02:35:06.628381Z", "shell.execute_reply": "2023-03-26T02:35:06.627483Z", "shell.execute_reply.started": "2023-03-26T02:35:05.771774Z" }, "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": 5, "id": "f21fff31-0da6-4c1a-bf7c-8c4a1d4a3ecf", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T02:35:15.880503Z", "iopub.status.busy": "2023-03-26T02:35:15.879646Z", "iopub.status.idle": "2023-03-26T02:35:15.919358Z", "shell.execute_reply": "2023-03-26T02:35:15.918271Z", "shell.execute_reply.started": "2023-03-26T02:35:15.880461Z" }, "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": 24, "id": "50a5e0f9-3850-48ac-9f3a-f5a7be51a7fd", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T05:32:21.320792Z", "iopub.status.busy": "2023-03-26T05:32:21.319878Z", "iopub.status.idle": "2023-03-26T05:32:21.453629Z", "shell.execute_reply": "2023-03-26T05:32:21.452854Z", "shell.execute_reply.started": "2023-03-26T05:32:21.320739Z" }, "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": "41c81dfc-ee3a-4934-8f02-077e3f07e5fc", "metadata": {}, "source": [ "## 导出汇总信息" ] }, { "cell_type": "code", "execution_count": 12, "id": "1106fa5d-f0dd-4af4-bc39-7b106786b438", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T02:50:54.853003Z", "iopub.status.busy": "2023-03-26T02:50:54.852133Z", "iopub.status.idle": "2023-03-26T02:50:54.947226Z", "shell.execute_reply": "2023-03-26T02:50:54.946509Z", "shell.execute_reply.started": "2023-03-26T02:50:54.852962Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ok!\n" ] } ], "source": [ "filename = 'data/杨庙补充汇总信息.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "list_item = ['name','bh','sex','phone','unit','id_num']\n", "list_data = []\n", "\n", "for k, v in dict1.items():\n", " list_mx = []\n", " list_mx.append(k)\n", " for item in list_item:\n", " if item in v.keys():\n", " list_mx.append(v[item])\n", " else:\n", " list_mx.append('')\n", " list_data.append(list_mx)\n", "#print(list_data) \n", "filename = 'data/羊庙汇总情况表.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "#sheet.append(title)\n", "for row in list_data:\n", " sheet.append(row)\n", " \n", "wb.save(filename) \n", "print('ok!')" ] }, { "cell_type": "markdown", "id": "d31fa9b7-26d8-4101-94d1-f41723428aa9", "metadata": {}, "source": [ "## 成年问卷导入" ] }, { "cell_type": "code", "execution_count": 25, "id": "dc20aabb-3942-49b9-8841-8e8a0823033a", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T05:33:34.447848Z", "iopub.status.busy": "2023-03-26T05:33:34.446983Z", "iopub.status.idle": "2023-03-26T05:33:34.654132Z", "shell.execute_reply": "2023-03-26T05:33:34.653397Z", "shell.execute_reply.started": "2023-03-26T05:33:34.447806Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "59\n", "350 不在清理名单中\n", "341 不在清理名单中\n", "76 不在清理名单中\n" ] } ], "source": [ "import openpyxl\n", "import json\n", "\n", "filename = 'data/杨庙补充汇总信息.json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl)\n", "wb = openpyxl.load_workbook('data/羊庙问卷统计表(成年组).xlsx')\n", "sheet = wb.active\n", "# sheets = wb.sheetnames\n", "\n", "\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", " if str(k) not in dict2.keys():\n", " print(k,'不在清理名单中')\n", "\n", "#print(dict1)" ] }, { "cell_type": "markdown", "id": "75dda87e-804e-42ba-b1a4-08c8a8b65050", "metadata": {}, "source": [ "## 老年问卷导入" ] }, { "cell_type": "code", "execution_count": 26, "id": "09a354e6-a07a-40b8-9b8c-3499fb0b7c28", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T05:35:40.679302Z", "iopub.status.busy": "2023-03-26T05:35:40.678787Z", "iopub.status.idle": "2023-03-26T05:35:41.117597Z", "shell.execute_reply": "2023-03-26T05:35:41.116797Z", "shell.execute_reply.started": "2023-03-26T05:35:40.679268Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(192, 190, 194, 195, 196, 197, 198, 18, 17, 16, 15, 14, 13, 12, 11, 9, 8, 7, 6, 5, 4, 436, 120, 121, 122, 124, 123, 130, 126, 133, 136, 135, 137, 138, 139, 140, 141, 142, 143, 144, 151, 150, 157, 158, 159, 160, 166, 167, 118, 117, 116, 115, 114, 111, 110, 109, 106, 105, 103, 102, 101, 100, 98, 96, 95, 94, 93, 90, 89, 88, 87, 86, 85, 83, 82, 80, 79, 77, 76, 230, 231, 237, 235, 233, 234, 239, 236, 238, 241, 243, 244, 242, 249, 256, 257, 258, 164, 165, 168, 162, 163, 74, 75, 73, 67, 59, 57, 56, 55, 53, 52, 49, 48, 47, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29, 26, 25, 24, 23, 170, 172, 169, 171, 175, 179, 183, 184, 186, 187, 188, 289, 290, 293, 294, 296, 305, 307, 308, 306, 310, 309, 311, 312, 316, 203, 199, 202, 207, 209, 210, 214, 212, 211, 216, 218, 219, 220, 221, 226, 227, 222, 223, 229, 232, 398, 401, 399, 403, 405, 406, 407, 415, 416, 6002, 424, 430, 346, 349, 348, 353, 357, 355, 351, 356, 362, 363, 364, 365, 369, 368, 371, 373, 377, 379, 376, 372, 378, 382, 386, 387, 393, 392, 396, 400, 314, 317, 318, 324, 323, 322, 326, 325, 328, 331, 329, 330, 332, 334, 335, 336, 337, 333, 338, 339, 340, 341, 297, 343, 344, 259, 262, 264, 260, 265, 267, 272, 271, 274, 2734, 275, 277, 276, 280, 281, 284, 283, 282, 286, 288, 228, 345)\n", "264\n", "76 不在清理名单中\n", "6002 不在清理名单中\n", "341 不在清理名单中\n", "2734 不在清理名单中\n" ] } ], "source": [ "import openpyxl\n", "import json\n", "\n", "filename = 'data/杨庙补充汇总信息.json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl)\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", " if str(k) not in dict2.keys():\n", " print(k,'不在清理名单中')\n", "#print(dict1)" ] }, { "cell_type": "markdown", "id": "3262d713-92a4-4790-81a3-976ff308ee3d", "metadata": {}, "source": [ "## 统计网络问卷信息" ] }, { "cell_type": "code", "execution_count": 35, "id": "08980670-fda9-4660-a619-2f5f5ed8d334", "metadata": { "execution": { "iopub.execute_input": "2023-03-26T05:43:49.134911Z", "iopub.status.busy": "2023-03-26T05:43:49.134063Z", "iopub.status.idle": "2023-03-26T05:43:49.161445Z", "shell.execute_reply": "2023-03-26T05:43:49.160406Z", "shell.execute_reply.started": "2023-03-26T05:43:49.134869Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "68\n", "{'13854631833': {'bh': '107'}, '19861788562': {'bh': '125'}, '15266081872': {'bh': '127'}, '13156069338': {}, '13345052671': {'bh': '132'}, '15963865456': {'bh': '134'}, '13589963798': {'bh': '147'}, '15266036408': {'bh': '145'}, '15615927087': {'bh': '146'}, '15954667259': {'bh': '149'}, '15005460118': {'bh': '148'}, '13562258927': {'bh': '161'}, '15005462524': {'bh': '173'}, '13963366034': {'bh': '177'}, '13205470588': {'bh': '178'}, '18554729698': {'bh': '181'}, '15254635911': {'bh': '185'}, '13563362898': {'bh': '193'}, '13054647833': {'bh': '191'}, '18354617776': {'bh': '200'}, '15154688368': {}, '18854629813': {'bh': '201'}, '18562102002': {'bh': '208'}, '13864783585': {'bh': '213'}, '15605462676': {'bh': '240'}, '13465265613': {'bh': '248'}, '13220500809': {'bh': '250'}, '15066041517': {'bh': '251'}, '13792096985': {'bh': '263'}, '19854682392': {'bh': '279'}, '13615463389': {'bh': '292'}, '13774903629': {'bh': '295'}, '18954613587': {'bh': '298'}, '17754651363': {'bh': '299'}, '18954000351': {'bh': '300'}, '13054600318': {'bh': '313'}, '18865960502': {'bh': '319'}, '13406131488': {'bh': '320'}, '13562255576': {'bh': '98765'}, '13465295658': {'bh': '342'}, '13220513789': {'bh': '347'}, '13864748012': {'bh': '360'}, '13562265739': {'bh': '358'}, '19963618373': {'bh': '359'}, '19854686796': {}, '13295460363': {'bh': '366'}, '13685465758': {}, '15553892229': {'bh': '98766'}, '18354635695': {'bh': '374'}, '15550538292': {'bh': '98767'}, '18854635086': {'bh': '383'}, '13054697632': {'bh': '384'}, '15666720188': {'bh': '385'}, '13165468652': {'bh': '388'}, '18678172677': {}, '18653397717': {}, '15006438600': {}, '15166222577': {'bh': '412'}, '18678666770': {'bh': '410'}, '18325462281': {'bh': '420'}, '13884922007': {'bh': '421'}, '13563354399': {}, '13176613151': {'bh': '423'}, '15666387708': {}, '15154628223': {'bh': '426'}, '18706653521': {'bh': '429'}, '13287383597': {'bh': '435'}, '13127192803': {'bh': '434'}}\n", "13156069338\n", "15154688368\n", "19854686796\n", "13685465758\n", "18678172677\n", "18653397717\n", "15006438600\n", "13563354399\n", "15666387708\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(dict3)\n", "for k, v in dict3.items():\n", " if 'bh' not in v.keys():\n", " print(k)" ] }, { "cell_type": "code", "execution_count": null, "id": "f69677a3-57bb-43b0-9d62-38330d86bddd", "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.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }