Files
jupyter/体测单位/东营羊庙.ipynb
T
2023-03-24 22:45:41 +08:00

14 KiB

调查报告线下数据管理

羊庙人员信息导入

In [33]:
import json

filename = 'data/羊庙测试人员信息.json'

with open(filename,'r') as fl:
    dict1 = json.load(fl) 
dict2 = {}
for k,v in dict1.items():
    for item in v:
        bh = item['avatar_id']
        del item['avatar_id']
        dict2[bh] = item
filename = 'data/羊庙人员名单.json'
with open(filename, 'w') as fl:
    json.dump(dict2, fl, ensure_ascii=False)
print('ok')
ok

获取参加体测人员编号

In [40]:
import json
import time
import csv

filename = '../item.json'
item = {}
unit = {}
with open(filename,'r') as fl:
    dict1 = json.load(fl) 
for k,v in dict1.items():
    item[k] = v
re_ta = {}
dict1 = {}
list1 = []
#print("\n运动项目信息:")
filename = 'data/140.csv'
with open(filename,'r',newline='') as csv_file:
    fl = csv.reader(csv_file,delimiter=',')
    header = next(fl)    
    for line in fl:
        #line = re.sub('[\r\n\f ]{1,}', '', line)
        list1.append(line)
list2 = []
for result in list1:
    user = int(result[2])
    if user not in list2:
        list2.append(user)
list2.sort()
print(list2)
465
[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]

根据风险筛选统计卡获取信息

In [63]:
import openpyxl
import json
import time

wb = openpyxl.load_workbook('data/杨庙运动风险筛查统计表.xlsx')
sheet = wb.active
person = {}
for n in range(2, sheet.max_row+1):
    code = int(sheet.cell(n, 1).value)
    person.setdefault(code, {})
    dict1 = {}
    if sheet.cell(n, 8).value is not None:
        name = sheet.cell(n, 8).value
    else:
        name ='不详'
    dict1['name'] = name
    if sheet.cell(n, 9).value is not None:
        dict1['birth'] = str(sheet.cell(n, 9).value).split(' ')[0]
    if sheet.cell(n, 10).value is not None:
        dict1['phone'] = sheet.cell(n, 10).value
    if sheet.cell(n,11).value is not None:
        dict1['id_num'] = sheet.cell(n,11).value
    person[code] = dict1
print(len(person))
filename = 'data/杨庙运动风险筛查统计表信息.json'
with open(filename, 'w') as fl:
    json.dump(person, fl, ensure_ascii=False,default=str)
print('ok')
440
ok

根据恢复版获取信息

In [60]:
import openpyxl
import json
import time

wb = openpyxl.load_workbook('data/羊庙恢复版.xlsx')
sheet = wb.active
person = {}
for n in range(2, sheet.max_row+1):
    if sheet.cell(n, 4).value is not None:        
        code = int(sheet.cell(n, 4).value)
        person.setdefault(code, {})
        dict1 = {}
        name = sheet.cell(n, 5).value
        dict1['name'] = name
        dict1['bh'] = n - 1       
        if sheet.cell(n, 9).value is not None:
            dict1['phone'] = sheet.cell(n, 9).value
        if sheet.cell(n,8).value is not None:
            dict1['id_num'] = sheet.cell(n,8).value
        person[code] = dict1
print(len(person))
filename = 'data/杨庙恢复版信息.json'
with open(filename, 'w') as fl:
    json.dump(person, fl, ensure_ascii=False,default=str)
print('ok')
350
ok

成年问卷导入

In [ ]:
import openpyxl
import json


wb = openpyxl.load_workbook('data/羊庙问卷统计表(成年组).xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
dict3 = {}
no_xinli = [108,389,268,270]
sheet = wb.active
data1 =list(sheet.values)
list_bh = data1[0][1:]
del data1[0]
print(len(list_bh))
for i in range(1,len(list_bh)+1):
    list2 = []
    
    for item in data1:
        list2.append(item[i])
    dict1[list_bh[i-1]] = list2
for k, v in dict1.items():
    if 0 in v:
        print(k)
59
108
389
268
270

老年问卷导入

In [ ]:
import openpyxl
import json


wb = openpyxl.load_workbook('data/羊庙问卷统计表(老年组).xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
dict3 = {}
no_xinli = [286]
sheet = wb.active
data1 =list(sheet.values)
list_bh = data1[0][1:]
print(list_bh)
del data1[0]
print(len(list_bh))
for i in range(1,len(list_bh)+1):
    list2 = []
    
    for item in data1:
        list2.append(item[i])
    dict1[list_bh[i-1]] = list2
for k, v in dict1.items():
    if 0 in v or ' ' in v:
        print(k)
print(dict1)
(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)
264
264
In [ ]: