Parsing module for tableview.
Provides CSV/TSV ingestion from files or streams, column-type detection, and the core TableData structure used throughout the application.
Types
ColumnType = enum ctString, ## Column contains arbitrary text values. ctInt, ## All non-empty values parse as integers. ctFloat ## All non-empty values parse as floating-point numbers.
- Detected data type for a table column.
TableData = object headers*: seq[string] ## Column header names (one per column). rows*: seq[seq[string]] ## Data rows; each inner seq has one field per column. columnWidths*: seq[int] ## Rendering widths (capped at `maxColWidth`) per column. columnTypes*: seq[ColumnType] ## Detected type for each column. hiddenColumns*: seq[bool] ## Per-column visibility flag; `true` means hidden.
- Holds the parsed contents of a delimited file.
Procs
proc detectDelimiter(filename: string): char {....raises: [IOError], tags: [ReadIOEffect], forbids: [].}
- Detect whether file is TSV or CSV by checking first line
proc parseDelimitedFile(filename: string; delimiter: char = '\t'; skipLines: int = 0; skipPrefix: string = ""; hasHeader: bool = true; maxColWidth: int = 20): TableData {. ...raises: [IOError], tags: [ReadIOEffect], forbids: [].}
- Parse a TSV or CSV file and return table data with calculated column widths
proc parseDelimitedStream(stream: Stream; delimiter: char = '\x00'; skipLines: int = 0; skipPrefix: string = ""; hasHeader: bool = true; maxColWidth: int = 20): TableData {. ...raises: [IOError, OSError], tags: [ReadIOEffect], forbids: [].}
- Parse a TSV or CSV from a stream (e.g., stdin) If delimiter is '0', it will be auto-detected from the first line