from os.path import join
import csv
DATA_FOLDER = 'tempdata'
WRANGLED_DATA_FILE = join(DATA_FOLDER, 'wrangled2014.csv')

newfile = open(WRANGLED_DATA_FILE, 'r')
datarows = list(csv.DictReader(newfile))

for r in datarows:
	r['total'] = int(r['total'])
	r['males'] = int(r['males'])
	r['females'] = int(r['females'])
	r['ratio'] = int(r['ratio'])

print("Most popular names with less than 60% gender skew:")
hugedatarows = sorted(datarows, key = lambda r: r['total'], reverse = True)
fxrows = [r for r in datarows if r['ratio'] <= 60]

for row in fxrows[0:5]:
	print(row['name'].ljust(10),row['gender'], row['ratio'], row['total'])