from datetime import datetime from million.analyze.find_holes import compute_sequences, find_holes from million.analyze.retain_counts import retain_counts import million.parse.fb_exports as fb DATA_PATH = './data/' export = fb.parse_dirfiles(DATA_PATH) filtered = retain_counts(export.messages) sequences = compute_sequences(filtered) actual_counted = sum([s.length() for s in sequences]) print(f"Actual counted: {actual_counted}") holes = find_holes(filtered) print(len(holes)) for hole in holes: print(f"{hole.start() + 1} -> {hole.end() - 1} ({hole.length() - 2})") # lets export a csv file of the holes and the people responsible for them with open('output/holes.csv', 'w') as f: f.write('début,fin,taille,responsable1,responsable2,date1,date2\n') for hole in holes: date_start = datetime.utcfromtimestamp( hole.start_message.timestamp_ms / 1000.0).strftime('%Y-%m-%d %H:%M:%S') date_end = datetime.utcfromtimestamp( hole.end_message.timestamp_ms / 1000.0).strftime('%Y-%m-%d %H:%M:%S') f.write( f"{hole.start()}," f"{hole.end()}," f"{hole.length()}," f"{hole.start_message.sender_name}," f"{hole.end_message.sender_name}," f"{date_start},{date_end}\n" )