pluto.tools.TableReader¶
- class pluto.tools.TableReader(filename, comment_char='#', delimiter='\t')[source]¶
Handler for reading a table with comments
Allows for parsing file attributes and rows without loading the whole file into memory
Note
Input file must have column headers!
- Parameters
filename (str) – path to input file
comment_char (str) – comment character for the file
delimiter (str) – file field delimiter
Examples
Example usage:
table_reader = TableReader(input_maf_file) comment_lines = table_reader.comment_lines fieldnames = table_reader.get_fieldnames() records = [ rec for rec in table_reader.read() ]
- __init__(filename, comment_char='#', delimiter='\t')[source]¶
- Parameters
filename (str) – path to input file
comment_char (str) – comment character for the file
delimiter (str) – file field delimiter
Examples
Example usage:
table_reader = TableReader(input_maf_file) comment_lines = table_reader.comment_lines fieldnames = table_reader.get_fieldnames() records = [ rec for rec in table_reader.read() ]
Methods
__init__
(filename[, comment_char, delimiter])- param filename
path to input file
count
()Return the total number of records in the table
get_fieldnames
()returns the list of fieldnames for the table
get_reader
(fin)returns the csv.DictReader for the table rows, skipping the comments
read
()iterable to get the record rows from the table, skipping the comments