pluto.tools.parse_header_comments¶
- pluto.tools.parse_header_comments(filename, comment_char='#')[source]¶
Parse a file with comments in its header to return the comments and the line number to start reader from.
- Parameters
filename (str) – path to input file
comment_char (str) – comment character
- Returns
list – a list of comment lines from the file header
int – the line number on which file data starts (the line after the last comment)
Examples
Example usage:
comments, start_line = parse_header_comments(filename) with open(portal_file) as fin: while start_line > 0: next(fin) start_line -= 1 reader = csv.DictReader(fin, delimiter = ' ') # header_line = next(fin) portal_lines = [ row for row in reader ]