James Taylor avatar James Taylor committed 1988f04

Fix 'first line is header' support in tabular.io

Comments (0)

Files changed (1)

lib/bx/tabular/io.py

 from itertools import *
 from UserDict import DictMixin
 
+FIRST_LINE_IS_HEADER = object()
+
 class ParseError( Exception ):
     def __init__( self, *args, **kwargs ):
         Exception.__init__( self, *args )
                 return Comment( line )
             else:
                 return self.next()
+        # Force header?
+        if self.header is FIRST_LINE_IS_HEADER and self.linenum == 1:
+            self.header = self.parse_header( line )
+            if self.return_header:
+                return self.header
+            else:
+                return self.next()
         # Is it a comment line?
         for comment_line_start in self.comment_lines_startswith:
             if line.startswith( comment_line_start ):
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.