Files
jupyter/体测单位/东营羊庙.ipynb
T
2023-03-25 13:02:51 +08:00

500 lines
14 KiB
Plaintext

{
"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": 33,
"id": "9b2b755e-049e-48c5-87d3-dd37dceb59fe",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-24T13:14:35.940432Z",
"iopub.status.busy": "2023-03-24T13:14:35.939897Z",
"iopub.status.idle": "2023-03-24T13:14:36.013683Z",
"shell.execute_reply": "2023-03-24T13:14:36.012420Z",
"shell.execute_reply.started": "2023-03-24T13:14:35.940384Z"
},
"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)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "00e9f538-c0f5-46a0-b768-51480ad3fbaf",
"metadata": {},
"source": [
"## 获取参加体测人员编号"
]
},
{
"cell_type": "code",
"execution_count": 86,
"id": "d89e0e5e-0782-40a3-bba3-862cc9865d4e",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-25T03:42:53.495948Z",
"iopub.status.busy": "2023-03-25T03:42:53.495372Z",
"iopub.status.idle": "2023-03-25T03:42:53.531455Z",
"shell.execute_reply": "2023-03-25T03:42:53.530000Z",
"shell.execute_reply.started": "2023-03-25T03:42:53.495901Z"
},
"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": 63,
"id": "e76837e8-cdf4-41e0-9d51-6ae5223de813",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-24T14:43:32.834711Z",
"iopub.status.busy": "2023-03-24T14:43:32.834163Z",
"iopub.status.idle": "2023-03-24T14:43:32.955657Z",
"shell.execute_reply": "2023-03-24T14:43:32.954341Z",
"shell.execute_reply.started": "2023-03-24T14:43:32.834663Z"
},
"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'] = 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": 60,
"id": "1293cdaa-1fdf-43a5-99ce-a031a76f6688",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-24T14:42:34.578240Z",
"iopub.status.busy": "2023-03-24T14:42:34.577707Z",
"iopub.status.idle": "2023-03-24T14:42:35.818413Z",
"shell.execute_reply": "2023-03-24T14:42:35.816872Z",
"shell.execute_reply.started": "2023-03-24T14:42:34.578193Z"
}
},
"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",
" if sheet.cell(n, 9).value is not None:\n",
" dict1['phone'] = 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",
" 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": 92,
"id": "f21fff31-0da6-4c1a-bf7c-8c4a1d4a3ecf",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-25T03:53:57.819611Z",
"iopub.status.busy": "2023-03-25T03:53:57.819079Z",
"iopub.status.idle": "2023-03-25T03:53:57.862720Z",
"shell.execute_reply": "2023-03-25T03:53:57.861589Z",
"shell.execute_reply.started": "2023-03-25T03:53:57.819563Z"
},
"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": "d31fa9b7-26d8-4101-94d1-f41723428aa9",
"metadata": {},
"source": [
"## 成年问卷导入"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc20aabb-3942-49b9-8841-8e8a0823033a",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-24T14:39:51.668924Z",
"iopub.status.busy": "2023-03-24T14:39:51.668395Z",
"iopub.status.idle": "2023-03-24T14:39:51.935114Z",
"shell.execute_reply": "2023-03-24T14:39:51.933808Z",
"shell.execute_reply.started": "2023-03-24T14:39:51.668877Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"59\n",
"108\n",
"389\n",
"268\n",
"270\n"
]
}
],
"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": {
"execution": {
"iopub.execute_input": "2023-03-24T14:39:29.249485Z",
"iopub.status.busy": "2023-03-24T14:39:29.248954Z"
},
"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",
"264\n"
]
}
],
"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": "code",
"execution_count": null,
"id": "10198e81-cea0-475a-bce7-4a4829320517",
"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
}