diff unfold_column.py @ 0:5314e5d6f040 draft

Imported from capsule None
author bgruening
date Thu, 29 Jan 2015 07:53:17 -0500
parents
children 37e1eb05b1b4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unfold_column.py	Thu Jan 29 07:53:17 2015 -0500
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+import sys
+
+out = open(sys.argv[4], 'w+')
+
+with open(sys.argv[1]) as handle:
+    for line in handle:
+        cols = line.split('\t')
+        unfolding_column = int(sys.argv[2]) - 1
+        column_content = cols[ unfolding_column ]
+        for elem in column_content.split( sys.argv[3] ):
+            out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) )
+out.close()