import csv

hashMap = dict()
familyMap = dict()
perClass = 1000

#balancedLabels.csv created with balancedHashList.py
with open('balancedLabels.csv') as labels:
	csvIn = csv.reader(labels)
	for hash in csvIn:
		hashMap[hash[0]] = hash[1]

#byte entropy histograms (beh) directory created with downloadbeh.py
#downloaded.csv created with `ls ./behDir > downloaded.csv`
with open('downloaded.csv') as downloads:
	for hashline in downloads:
		hash = hashline.rstrip()
		family = hashMap[hash]
		if family in familyMap:
			familyMap[family].append(hash)
		else:
			familyMap[family] = [hash]

for family in familyMap:
	if len(familyMap[family]) >= perClass:
		i = 0
		for hash in familyMap[family]:
			if i < perClass:
				i += 1
				print hash + ',' + family
