import csv def makeoutput(infile, outfile): counter = 0 with open(infile) as tsvfile: reader = csv.reader(tsvfile, delimiter='\t') for row in reader: counter+=1 with open(outfile, 'wt') as tsvfile: tsv_writer = csv.writer(tsvfile, delimiter='\t') for i in range(counter): tsv_writer.writerow('S') makeoutput("test-A/in.tsv", "test-A/out.tsv") makeoutput("train/in.tsv", "train/out.tsv") makeoutput("dev-0/in.tsv", "dev-0/out.tsv")