Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Created July 29, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/fc30a8047af64b0dfc9a94fe4623350f to your computer and use it in GitHub Desktop.
Save Allwin12/fc30a8047af64b0dfc9a94fe4623350f to your computer and use it in GitHub Desktop.
import re
import matplotlib.pyplot as plt
with open('chat.txt', 'r') as f:
content = f.readlines()
all_dates = []
for line in content:
dates = re.findall(r'[0-9]+/[0-9]+/[0-9]+', line)
if dates:
all_dates.extend(dates)
unique_dates = list(set(all_dates))
tuple_date_freq_list = []
for date in unique_dates:
freq = all_dates.count(date)
tuple_date_freq_list.append((date, freq))
plt.bar(*zip(*tuple_date_freq_list))
plt.xticks(rotation=90)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment