code: Optimizing contact parsing

This commit is contained in:
Manos Katsomallos 2021-09-22 22:15:10 +02:00
parent 2704705ddf
commit fc7f7f6f90

View File

@ -30,9 +30,11 @@ rssi = 3
def main(args):
# Get contacts [tim, uid_a, uid_b] from previous parsing
cont = lmdk_lib.load_data(args, 'cont')
if cont.size == 0:
# Get contacts from previous parsing
cont_data = lmdk_lib.load_data(args, 'cont')
if cont_data.size == 0:
# Contacts [tim, uid_a, uid_b, rssi]
cont = []
try:
print('Extracting %s... ' %(os.path.abspath(args.arc)), end='', flush=True)
with zipfile.ZipFile(args.arc, 'r') as arc:
@ -46,14 +48,14 @@ def main(args):
for c in cont_l:
if c[uid_b] != '-1' and c[rssi] != '0' and c[uid_b] != '-2' and c[uid_a] != c[uid_b]:
# Add valid contact
cont.append([c[tim], c[uid_a], c[uid_b]])
cont.append([c[tim], c[uid_a], c[uid_b], c[rssi]])
print('[OK]')
except Exception as e:
print('[Error: %s]' %(e))
except Exception as e:
print('[Error: %s]' %(e))
# Save to results
lmdk_lib.save_data(args, np.array(cont), 'cont')
lmdk_lib.save_data(args, np.array(cont, np.float32), 'cont')
'''