from utils import load_data
specials = { 'South_Korea':'Korea_(South)', 'Russia':'Russian_Federation', 'New_Zealand':'New_Zealand_(Aotearoa)', 'Serbia':'Serbia_and_Montenegro', 'Croatia':'Croatia_(Hrvatska)', 'Vietnam':'Viet_Nam' }
data = load_data('country-codes.txt') D = dict() for line in data.strip().split('\n'): L = line.strip().split() D['_'.join(L[1:])] = L[0]
cL = list() data = load_data('scraped.txt') for line in data.strip().split('\n'): L = line.strip().split() i = len(L) - 4 country = '_'.join(L[1:i]) cL.append(country) if country in specials: k = specials[country] D[country] = D[k]
def f(k): return D[k] for country in sorted(cL, key=f): print D[country],'\t', country.replace('_',' ') |