Files
jupyter/体测单位/东营羊庙.ipynb
T
2023-03-25 13:02:51 +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 [86]:
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(len(list2))
465

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

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 [92]:
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()
set1 = set()
filename = 'data/杨庙恢复版信息.json'
with open(filename,'r') as fl:
    dict_base = json.load(fl)
for k, v in dict_base.items():
    set1.add(int(k))
filename = 'data/杨庙运动风险筛查统计表信息.json'

with open(filename,'r') as fl:
    dict1 = json.load(fl)
list_fx = []

for k,v in dict1.items():
    
    if int(k) in list2 and k not in dict_base.keys() and v['name'] != '不详':        
        set1.add(int(k))
#print(len(list_fx))
#print(len(set1)) 
for item in list2:
    if item not in set1:
        print(item)
103
314
555
666
777
999
1000
1001
2367
3456
6000
6001
6002
6003
6602
8888
8889
9999
10000
11112
66666
77777
88888
98000
99999
111111
888888
999998
999999
9999999
999999999

成年问卷导入

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 [ ]: