read_table

function of dascore.utils.tables source

read_table(
    path: Path ,
    what: str = nothing,
    skip: int = 0,
)-> ‘pd.DataFrame’

Read one strict CSV table.

Every cell arrives as text and the caller coerces it, so a column’s meaning is the field’s rather than whatever pandas inferred from the rows it happened to see. Only a truly empty cell is null: an empty cell means unset, and a document which writes NA means the string.

Parameters

Parameter Description
path The CSV file to read.
what What a table with no columns fails to state, for that error message.
skip Lines above the header, for a format which states something of its
own before its table. Read past before the table is parsed at all,
so nothing downstream has to agree about what those lines were. Row
numbers in errors still count from the top of the file, so they name
the line a reader would look at.

Examples

import tempfile
from pathlib import Path
from dascore.utils.tables import read_table
with tempfile.TemporaryDirectory() as folder:
    path = Path(folder) / "coupling.csv"
    _ = path.write_text("group,value\nrail,true\n")
    frame = read_table(path)
list(frame.columns), frame["value"][0]
(['group', 'value'], 'true')