Skip to content

ump_intake.parsing

module ump-intake

Parsing (stage 1): CSV or XLSX bytes, an inline series, or connector rows to a ParsedTable.

Title rows, blank rows and printed total or subtotal rows are separated from the data; hidden rows and merged cells in a workbook are reported as known issues. Moved here unchanged from apps/onboarding so the onboarding wizard and the data catalogue (apps/data) parse deliveries the same way.

class

class ParsedTable

Fields

NameTypeDefaultDescription
kindstr
filenamestr
raw_bytesbytes
columnslist[str]
rowslist[list[Any]]
printed_totalsdict[str, float]field(default_factory=dict)
issueslist[str]field(default_factory=list)
skipped_rowsint0
Methods and properties (2)

sha256 property

sha256: str

init constructor

ParsedTable(
self,
kind: str,
filename: str,
raw_bytes: bytes,
columns: list[str],
rows: list[list[Any]],
printed_totals: dict[str, float] = dict(),
issues: list[str] = list(),
skipped_rows: int = 0,
) -> None

Source: packages/ump-intake/src/ump_intake/parsing.py, line 25

function

def to_csv(
columns: list[str],
rows: list[list[Any]],
printed: dict[str, float] | None = None,
) -> str

CSV text with \n line ends; an optional printed Total row at the bottom.

Source: packages/ump-intake/src/ump_intake/parsing.py, line 41

function

def to_number(v: Any) -> float | None

Source: packages/ump-intake/src/ump_intake/parsing.py, line 53

function

def to_date(v: Any) -> date | None

Source: packages/ump-intake/src/ump_intake/parsing.py, line 72

function

def split_rows(
header: list[str],
body: list[list[Any]],
issues: list[str],
) -> tuple[list[list[Any]], dict[str, float], int]

Separate data rows from blank and printed total rows.

Source: packages/ump-intake/src/ump_intake/parsing.py, line 88

function

def header_index(rows: list[list[Any]]) -> int

First row with at least two non-empty, non-numeric cells.

Source: packages/ump-intake/src/ump_intake/parsing.py, line 113

function

def parse_csv_bytes(raw: bytes, filename: str) -> ParsedTable

Source: packages/ump-intake/src/ump_intake/parsing.py, line 122

function

def parse_xlsx_bytes(raw: bytes, filename: str, sheet: str | None = None) -> ParsedTable

Source: packages/ump-intake/src/ump_intake/parsing.py, line 134

function

def parse_inline(series: dict[str, Any]) -> ParsedTable

{dates, kpi, spend: {ch: [...]}, controls: {...}, kpi_name?} (the adapter SeriesData shape).

Source: packages/ump-intake/src/ump_intake/parsing.py, line 162

function

def parse_rows(
columns: Sequence[str],
rows: Sequence[Sequence[Any] | Mapping[str, Any]],
name: str = 'connected',
) -> ParsedTable

Rows read through a data connection (a list of lists, or of dicts read in columns order) to a table, so mapping suggestions and build_panel work on connected data exactly as on a file. Blank and printed total rows are separated the same way. raw_bytes is the CSV rendering, held in memory only: callers decide whether the copy policy lets it be stored.

Source: packages/ump-intake/src/ump_intake/parsing.py, line 178

function

def parse_upload(body: dict[str, Any]) -> ParsedTable

Source: packages/ump-intake/src/ump_intake/parsing.py, line 192

NameTypeValueDescription
TOTAL_REre.compile('^\\s*(grand\\s+)?(sub)?total\\b', re.IGNORECASE)