James Taylor avatar James Taylor committed b4d901b

table_filter.py: option to treat first line as header even if it does not
start with "#"

Comments (0)

Files changed (1)

scripts/table_filter.py

 cutting, again using field name or numbers.
 
 usage: %prog expression < table 
-    -H, --header:    keep header in output
-    -C, --comments:  keep comments in output
-    -c, --cols=1,2:  names or indexes of columns to keep
+    -H, --header:       keep header in output
+    -C, --comments:     keep comments in output
+    --force-header:     assume the first line is a header even if it does not start with "#"
+    -c, --cols=1,2:     names or indexes of columns to keep
 """
 
 import psyco_full
             expr = args[0]
         else:
             expr = None
+        if options.force_header:
+            force_header = bx.tabular.io.FIRST_LINE_IS_HEADER
+        else:
+            force_header = None
     except:
         doc_optparse.exception()
 
     # Compile expression for SPEED
     if expr: expr = compile( expr, '<expr arg>', 'eval' )
 
-    for element in bx.tabular.io.TableReader( sys.stdin ):
+    for element in bx.tabular.io.TableReader( sys.stdin, force_header=force_header ):
         if type( element ) is bx.tabular.io.Header:
             if keep_header: 
                 if cols:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.