code: Get contacts from previous parsing

This commit is contained in:
Manos Katsomallos 2021-09-22 22:02:25 +02:00
parent cfe3bcc87c
commit 2704705ddf

View File

@ -30,29 +30,30 @@ rssi = 3
def main(args): def main(args):
# All the contacts [tim, uid_a, uid_b]. # Get contacts [tim, uid_a, uid_b] from previous parsing
cont = [] cont = lmdk_lib.load_data(args, 'cont')
try: if cont.size == 0:
print('Extracting %s... ' %(os.path.abspath(args.arc)), end='', flush=True) try:
with zipfile.ZipFile(args.arc, 'r') as arc: print('Extracting %s... ' %(os.path.abspath(args.arc)), end='', flush=True)
print('[OK]') with zipfile.ZipFile(args.arc, 'r') as arc:
with io.TextIOWrapper(arc.open(args.cont), newline='\n') as dat: print('[OK]')
try: with io.TextIOWrapper(arc.open(args.cont), newline='\n') as dat:
print('Finding contacts... ', end='', flush=True) try:
# Get the contacts by skipping the header print('Finding contacts... ', end='', flush=True)
cont_l = list(csv.reader(dat, delimiter=','))[hdr:] # Get the contacts by skipping the header
# Check each contact cont_l = list(csv.reader(dat, delimiter=','))[hdr:]
for c in cont_l: # Check each contact
if c[uid_b] != '-1' and c[rssi] != '0' and c[uid_b] != '-2' and c[uid_a] != c[uid_b]: for c in cont_l:
# Add valid contact if c[uid_b] != '-1' and c[rssi] != '0' and c[uid_b] != '-2' and c[uid_a] != c[uid_b]:
cont.append([c[tim], c[uid_a], c[uid_b]]) # Add valid contact
print('[OK]') cont.append([c[tim], c[uid_a], c[uid_b]])
except Exception as e: print('[OK]')
print('[Error: %s]' %(e)) except Exception as e:
except Exception as e: print('[Error: %s]' %(e))
print('[Error: %s]' %(e)) except Exception as e:
# Save to results print('[Error: %s]' %(e))
lmdk_lib.save_data(args, np.array(cont), 'cont') # Save to results
lmdk_lib.save_data(args, np.array(cont), 'cont')
''' '''