您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

find_holes.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from datetime import datetime
  2. import million.analyze.find_holes as fh
  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 = fh.compute_sequences(filtered)
  9. actual_counted = sum([s.length() for s in sequences])
  10. print(f"Actual counted: {actual_counted}")
  11. merged = fh.merge_duplicates(sequences)
  12. merged = [s for s in merged if s.length() > 1]
  13. holes = fh.find_holes(filtered)
  14. print(len(holes))
  15. for hole in holes:
  16. print(f"{hole.start() + 1} -> {hole.end() - 1} ({hole.length() - 2})")
  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.length()},"
  29. f"{hole.start_message.sender_name},"
  30. f"{hole.end_message.sender_name},"
  31. f"{date_start},{date_end}\n"
  32. )