Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.