You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

find_holesV2.py 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. from datetime import datetime
  2. from million.analyze.find_holes import find_sequences_v2
  3. from million.analyze.retain_counts import retain_counts
  4. from million.parse.fb_exports import FacebookExportParser
  5. DATA_PATH = './data/'
  6. parser = FacebookExportParser()
  7. export = parser.parse(DATA_PATH)
  8. filtered = retain_counts(export.messages)
  9. sequences = find_sequences_v2(filtered)
  10. with open('output/holes.csv', 'w') as f:
  11. f.write('début,fin,taille,responsable,date2\n')
  12. for i in range(1, len(sequences)):
  13. hole_start = sequences[i-1].end+1
  14. hole_end = sequences[i].start-1
  15. hole_end_message = sequences[i].start_message
  16. hole_start_message = sequences[i-1].start_message
  17. date_start = datetime.utcfromtimestamp(
  18. hole_start_message.timestamp_ms / 1000.0).strftime('%Y-%m-%d %H:%M:%S')
  19. date_end = datetime.utcfromtimestamp(
  20. hole_end_message.timestamp_ms / 1000.0).strftime('%Y-%m-%d %H:%M:%S')
  21. f.write(
  22. f"{hole_start},"
  23. f"{hole_end},"
  24. f"{hole_end - hole_start + 1},"
  25. f"{hole_end_message.sender_name},"
  26. f"{date_start},{date_end}\n"
  27. )