from datetime import datetime from million.analyze.find_holes import find_sequences_v2 from million.analyze.retain_counts import retain_counts from million.parse.fb_exports import FacebookExportParser DATA_PATH = './data/' parser = FacebookExportParser() export = parser.parse(DATA_PATH) filtered = retain_counts(export.messages) sequences = find_sequences_v2(filtered) with open('output/holes.csv', 'w') as f: f.write('début,fin,taille,responsable,date2\n') for i in range(1, len(sequences)): hole_start = sequences[i-1].end+1 hole_end = sequences[i].start-1 hole_end_message = sequences[i].start_message hole_start_message = sequences[i-1].start_message 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_end - hole_start + 1}," f"{hole_end_message.sender_name}," f"{date_start},{date_end}\n" )