#1 load dictionary from file
file.map
key1 value1
key2 value2
FINE_TO_UNIVERSAL_MAP = dict(str.split() for str in read_file("file.map"))
#2 load files without new line
with open(file_name, "r") as in_file:
return in_file.read().splitlines()
#3
http://safehammad.com/downloads/python-idioms-2014-01-16.pdf
#4 Counter sort by value and print with percentage
total = sum(counter.values())
#for item in sorted(counter.items(), cmp=lambda x, y: cmp(y[1], x[1])):
for item in counter.most_common():
print "%- 25s\t%d\t%f%%" % (item[0], item[1], (float(item[1]) / total) * 100)