goatools.wr_tbl module

Contains generic table-writing functions. Data is expected to be a list of namedtuples.

kwargs (kws):

'title': First row will contain user-provided title string
'prt_if': Only print a line if user-specfied test returns True.
    prt_if is a lambda function with the data item's namedtuple as input.
    Example: prt_if = lambda nt: nt.p_uncorrected < 0.05
'sort_by' : User-customizable sort when printing.
    sortby is a lambda function with the data item's namedtuple as input.
    It is the 'key' used in the sorted function.
    Example: sort_by = lambda nt: [nt.NS, -1*nt.depth]
'hdrs' : A list of column headers to use when printing the table.
    default: The fields in the data's namedtuple is used as the column headers.
'sep': Separator used when printing the tab-separated table format.
    default: sep = ' '
'prt_flds' : Used to print a subset of the fields in the namedtuple or
    to control the order of the print fields
'fld2col_widths: A dictionary of column widths used when writing xlsx files.
'fld2fmt': Used in tsv files and xlsx files for formatting specific fields

For adding color or other formatting to a row based on value in a row:
    'ntfld_wbfmt': namedtuple field containing a value used as a key for a xlsx format
    'ntval2wbfmtdict': namedtuple value and corresponding xlsx format dict.
goatools.wr_tbl.prt_txt(prt, data_nts, prtfmt=None, nt_fields=None, **kws)[source]

Print list of namedtuples into a table using prtfmt.

goatools.wr_tbl.get_lines(data_nts, prtfmt=None, nt_fields=None, **kws)[source]

Print list of namedtuples into a table using prtfmt.

goatools.wr_tbl.prt_nts(data_nts, prtfmt=None, prt=sys.stdout, nt_fields=None, **kws)[source]

Print list of namedtuples into a table using prtfmt.

goatools.wr_tbl.wr_xlsx(fout_xlsx, data_xlsx, **kws)[source]

Write a spreadsheet into a xlsx file.

goatools.wr_tbl.wr_xlsx_sections(fout_xlsx, xlsx_data, **kws)[source]

Write xlsx file containing section names followed by lines of namedtuple data.

goatools.wr_tbl.wr_tsv(fout_tsv, tsv_data, **kws)[source]

Write a file of tab-separated table data

goatools.wr_tbl.prt_tsv_sections(prt, tsv_data, **kws)[source]

Write tsv file containing section names followed by lines of namedtuple data.

goatools.wr_tbl.prt_tsv(prt, data_nts, **kws)[source]

Print tab-separated table headers and data

goatools.wr_tbl.prt_tsv_hdr(prt, data_nts, **kws)[source]

Print tab-separated table headers

goatools.wr_tbl.prt_tsv_dat(prt, data_nts, **kws)[source]

Print tab-separated table data

goatools.wr_tbl.get_fmtflds(prtfmt)[source]

Return the fieldnames in the formatter text.

goatools.wr_tbl.get_fmtfldsdict(prtfmt)[source]

Return the fieldnames in the formatter text.

goatools.wr_tbl.mk_fmtfld(nt_item, joinchr=' ', eol='\n')[source]

Given a namedtuple, return a format_field string.