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

wrap_year.py 771B

12345678910111213141516171819202122232425262728
  1. from million.view.bar_chart import plot as bar_chart
  2. from million.analyze.count_participations import count_participations
  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. print(len(filtered))
  9. # split messages into months
  10. first = filtered[0].date.strftime("%Y-%m")
  11. last = filtered[-1].date.strftime("%Y-%m")
  12. months = {
  13. f"{year}-{month:02}": []
  14. for year in range(int(first[:4]), int(last[:4]) + 1)
  15. for month in range(1, 13)
  16. }
  17. for message in filtered:
  18. month = message.date.strftime("%Y-%m")
  19. months[month].append(message)
  20. for month, messages in months.items():
  21. print(f"{month}: {len(messages)}")