File tree 1 file changed +21
-2
lines changed
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -329,8 +329,27 @@ def fast_concat(*inputs: Path, output: Path) -> None:
329
329
)
330
330
331
331
@staticmethod
332
- def read_header (reader : io .Reader ) -> List [str ]:
332
+ def read_header (
333
+ reader : io .Reader ,
334
+ comment : str = "#" ,
335
+ ) -> List [str ]:
333
336
"""
334
337
Read the header from an open file.
338
+
339
+ Comment and empty lines will be ignored.
340
+
341
+ Args:
342
+ reader: An open, readable file
343
+ comment: The character which indicates the start of a comment line.
344
+
345
+ Returns:
346
+ A list of field names found in the header line.
335
347
"""
336
- return reader .readline ().rstrip ("\r \n " ).split ("\t " )
348
+
349
+ for line in reader :
350
+ if not line .startswith (comment ) and not line .strip () == "" :
351
+ break
352
+ else :
353
+ raise ValueError ("No header found" )
354
+
355
+ return line .rstrip ("\r \n " ).split ("\t " )
You can’t perform that action at this time.
0 commit comments