-
-
Notifications
You must be signed in to change notification settings - Fork 403
Expand file tree
/
Copy pathpageviews.py
More file actions
18 lines (15 loc) · 674 Bytes
/
pageviews.py
File metadata and controls
18 lines (15 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from pprint import pprint
results = {}
# page-requests-20200504-20200510.txt
# is a file containing stats from pageviews on the official Python documentation
# (including different versions and languages)
# grep -E '\.html$' page-requests-20200504-20200510.txt | grep -v tutorial | sed 's/3\..\///g' | sed 's/3\///g' | sed 's/2\///g' > pageviews.txt
pages = open('pageviews.txt').readlines()[:-1]
for p in pages:
count, key = int(p.split()[0]), p.split()[-1].strip()
if key in results:
results[key] += count
else:
results[key] = count
for p in sorted(list(results.items()), key=lambda x: x[1], reverse=True)[50:100]:
print(p[1], p[0][1:])