Created
March 14, 2017 21:57
-
-
Save plallin/165d085837e0cf46a223666d0b984f5b 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
file = open("recommendations.txt") | |
recommendation = {} | |
for line in file: | |
# print(line) | |
if line == "": | |
pass | |
else: | |
if line in recommendation: | |
recommendation[line] += 1 | |
else: | |
recommendation[line] = 0 | |
import operator | |
sorted_recommendation = sorted(recommendation.items(), key=operator.itemgetter(1), reverse=True) | |
with open("sorted_recommendations_asx.txt", "a") as out: | |
for elem in sorted_recommendation: | |
out.write("{} ({} points)\n".format(elem[0].strip(), elem[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment