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_holes.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from datetime import datetime
  2. from million.analyze.find_holes import compute_sequences, find_holes
  3. from million.analyze.retain_counts import retain_counts
  4. import million.parse.fb_exports as fb
  5. DATA_PATH = './data/'
  6. export = fb.parse_dirfiles(DATA_PATH)
  7. filtered = retain_counts(export.messages)
  8. sequences = compute_sequences(filtered)
  9. actual_counted = sum([s.length() for s in sequences])
  10. print(f"Actual counted: {actual_counted}")
  11. holes = find_holes(filtered)
  12. print(len(holes))
  13. for hole in holes:
  14. print(f"{hole.start() + 1} -> {hole.end() - 1} ({hole.length() - 2})")
  15. # lets export a csv file of the holes and the people responsible for them
  16. with open('output/holes.csv', 'w') as f:
  17. f.write('début,fin,taille,responsable1,responsable2,date1,date2\n')
  18. for hole in holes:
  19. date_start = datetime.utcfromtimestamp(
  20. hole.start_message.timestamp_ms / 1000.0).strftime('%Y-%m-%d %H:%M:%S')
  21. date_end = datetime.utcfromtimestamp(
  22. hole.end_message.timestamp_ms / 1000.0).strftime('%Y-%m-%d %H:%M:%S')
  23. f.write(
  24. f"{hole.start()},"
  25. f"{hole.end()},"
  26. f"{hole.length()},"
  27. f"{hole.start_message.sender_name},"
  28. f"{hole.end_message.sender_name},"
  29. f"{date_start},{date_end}\n"
  30. )