Skip to content

Instantly share code, notes, and snippets.

@tianhuil
Created January 9, 2014 04:28
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 tianhuil/8329413 to your computer and use it in GitHub Desktop.
Save tianhuil/8329413 to your computer and use it in GitHub Desktop.
col2tsv: converts a single column by breaking it up by the first column
#!/usr/bin/env python
import sys
n_rows = int(sys.argv[1])
data = map(lambda x: [], xrange(n_rows))
for k, line in enumerate(sys.stdin):
data[k % n_rows] += [line.rstrip()]
for d in data:
print "\t".join(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment