Created
July 29, 2020 15:11
-
-
Save Allwin12/fc30a8047af64b0dfc9a94fe4623350f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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