Permalink
Browse files

merged

  • Loading branch information...
1 parent 1110c23 commit ecc91398845173525c56c18191afaefee1625d58 Brendan O'Connor committed Jul 20, 2010
Showing with 7 additions and 5 deletions.
  1. +3 −3 hwrap
  2. +4 −2 tsvawk
View
6 hwrap
@@ -12,7 +12,8 @@ cat file_with_header.tsv | hwrap grep bla
cat file_with_header.tsv | hwrap bash -c "grep bla | head"
"""
-import sys,os
+import sys,os,subprocess
+
if sys.stdin.isatty():
print>>sys.stderr, __doc__.strip()
sys.exit(1)
@@ -21,5 +22,4 @@ sys.stdout = open('/dev/stdout','w',buffering=0)
header = sys.stdin.readline()
print header[:-1]
args = sys.argv[1:]
-os.execvp( args[0], args )
-#os.execvp("ls", ["--color","/"])
+subprocess.call(args, stdin=sys.stdin, stdout=sys.stdout)
View
6 tsvawk
@@ -9,8 +9,7 @@ tsvawk '$count >= 5'
Your awk script will *not* see the header line from the file; this script absorbs it.
-The consequence is that the output doesn't get a header; you could always do
-echo c1 c2 | ssv2tsv to get it yourself, perhaps.
+ -r: repeat the header on output too. (Only good for "print $0" sorts of scripts.)
"""
import sys,os
@@ -25,6 +24,9 @@ flags = []
for i,colname in enumerate(colnames):
flags += ["-v", "%s=%s" % (colname, i+1)]
+if '-r' in sys.argv:
+ print header[:-1]
+ sys.argv.pop(sys.argv.index('-r'))
#print flags
args = ["tabawk"] + flags + sys.argv[1:]
os.execvp( "tabawk", args )

0 comments on commit ecc9139

Please sign in to comment.