1 # Q: Who are the 5 most active editors on articles in Harry Potter? How may edits have they made?
3 from csv import DictReader
5 # read in the input file and count by day
6 input_file = open("hp_wiki.tsv", 'r', encoding="utf-8")
9 for row in DictReader(input_file, delimiter="\t"):
12 if user in edits_by_editor:
13 edits_by_editor[user] = edits_by_editor[user] + 1
15 edits_by_editor[user] = 1
19 # I used this answer here:
20 # https://stackoverflow.com/questions/613183/sort-a-python-dictionary-by-value
23 for user in sorted(edits_by_editor, key=edits_by_editor.get, reverse=True):
24 print(user + " : " + str(edits_by_editor[user]))
28 num_printed = num_printed + 1