say the file has the following content:
Xkr4 0 0 0 0
Gm1992 0 0 0 0
Gm37381 0 0 0 0
Rp1 0 0 0 0
Rp1.1 0 0 0 0
Sox17 0 0 0 0
f=open(tsv_path, 'r')
transposed_iterator = zip(*csv.reader(open(tsv_path), delimiter = '\t'))
with open(output_tsv_path, 'w') as out:
for row in transposed_iterator:
out.write(delimiter.join(row) + '\n')
Result:
Xkr4 Gm1992 Gm37381 Rp1 Rp1.1 Sox17
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
The above lines exactly do what I want but the problem is I am using very old jython which doesn't contain csv module. How can I do it without csv module?