Skip to content

Instantly share code, notes, and snippets.

@Drunkar
Last active August 4, 2016 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drunkar/6750637 to your computer and use it in GitHub Desktop.
Save Drunkar/6750637 to your computer and use it in GitHub Desktop.
import sys
def transposition(infile, outfile):
with open(infile, "r") as fi:
table = []
for line in fi:
table.append(line.rstrip().split("\t"))
table = map(list, zip(*table))
with open(outfile, "w") as fo:
for row in table:
fo.write("\t".join(row) + "\n")
infile = "input_tsv.txt"
outfile = "output_tsv.txt"
transposition(infile, outfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment