Local data¶
All of these are importable from the top-level package (t3.filter_rows,
t3.to_csv, ...). See the local data guide.
filter_rows
¶
filter_rows(rows: Sequence[Mapping[str, Any]], match: str | Path | Sequence[Mapping[str, Any]], *, columns: Sequence[str] | None = None, on_unmatched: OnUnmatched = 'warn') -> list[dict[str, Any]]
Keep the rows that match a CSV/TSV file or a list of dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
Sequence[Mapping[str, Any]]
|
The rows to filter, e.g. from |
required |
match
|
str | Path | Sequence[Mapping[str, Any]]
|
A CSV or TSV path, or a list of dicts. |
required |
columns
|
Sequence[str] | None
|
Columns to compare. Defaults to every column of the match
file. Dotted paths such as |
None
|
on_unmatched
|
OnUnmatched
|
What to do when a match line finds no row: |
'warn'
|
Values compare as stripped strings. Results follow the order of match.
to_csv
¶
to_csv(rows: Sequence[Mapping[str, Any]], path: str | Path | None = None, *, columns: Sequence[str] | None = None, strip_empty: bool = False) -> Path
Write rows to CSV (UTF-8 with a BOM, so Excel opens it cleanly). Returns the path.
Nested objects become dotted columns (item.name); lists are written as
JSON text. columns picks and orders columns; strip_empty drops
columns that are empty in every row.
Without path, the file is <dataModel>__<license>__<timestamp>.csv
in the current folder. A path that is an existing folder, or ends with
/, gets that default name inside it (to_csv(rows, "output/")).
Missing folders are created.
to_json
¶
to_json(rows: Sequence[Mapping[str, Any]] | Mapping[str, Any], path: str | Path | None = None, *, lines: bool = False) -> Path
Write rows as indented JSON, or one object per line with lines=True.
path works as in to_csv: leave it out, or pass a folder, for a
<dataModel>__<license>__<timestamp>.json (or .jsonl) file name.
read_rows
¶
Read rows back from a JSON, JSON Lines, CSV or TSV file.
flatten
¶
Nested objects become dotted keys; lists become JSON text.
inspect
¶
Browse rows in the Textual inspector (needs t3api-utils[tui]).
t3.pick_file() is on the Prompts page.