# -*- coding: utf-8 -*-

import argparse,codecs


def main(inputFile,outputFile,rows):
	sl = set()
	with codecs.open(rows,'r','utf8') as p:
		for line in p:
			sl.add(line.strip())

	with codecs.open(inputFile,'r','utf8') as p:
		with codecs.open(outputFile,'w','utf8') as o:
			for line in p:
				if line.strip().split(';')[0] in sl:
					o.write(line)

if __name__ == '__main__':
	parser = argparse.ArgumentParser(description='Intersection tuples with list of words')
	parser.add_argument('-i', '--in', dest = 'inFile', required=True, 
			help = 'File with tuples')
	parser.add_argument('-o','--out', dest = 'outFile', required=True, 
			help = 'Output file')
	parser.add_argument('--row-words', dest = 'rows',
			help = 'File with words to intersect with rows')

	args = parser.parse_args()

	main(args.inFile,args.outFile,args.rows)
