Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

find_holes.py 1.4KB

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