Expand description
§rich-data
Tabular data for rs-rich:
one row source contract with adapters behind it, so a file, a stream of
records or a query result becomes a table without hand-written glue. Not
a port of anything upstream; it builds on rich-ext’s public API only.
RowSource: column names, an optionalSchema(rich_ext’s format-neutral model) and rows ofValues, one at a time.Rowsholds them in memory and renders throughrich_ext’sTableData.- Adapters:
csv(CSV and TSV through the port of Python’scsvsniffer and reader thatrich --csvuses),jsonl(JSON Lines),serialize(anyserde::Serializerows), andarrow(ArrowRecordBatches, behind the off-by-defaultarrowfeature). er: an ER diagram of aSchemaor of SQL DDL, throughrs-rich-diagram, behind the off-by-defaulterfeature.infer: column types (integers, floats, booleans, dates, timestamps, nulls, text) with the evidence for each, on request.stats: per-column count, nulls, distinct values, min, max, mean, median, quantiles and top values, as a table or under each heading.window: rows forrich_ext’s virtualised tables:Rowsby index, andRowWindow, one window of a forward-only source read in constant memory.sql: a query result set (ResultSet) with typed alignment,NULLmarked apart from empty text, and a row count.profile: a bounded profile of any row source (types, nulls, distinct values, statistics, histograms or top values, and a missing-value map), sampled when the input is long, as JSON or drawn; and of JSON records path by path, with presence and type mixes.quality: data quality check results (pass, warn, fail, error, with observed and expected values and failing rows) as a report.
Conditional styles for the tables these rows become are
rich_ext::table::rules.
use rich::Console;
use rich_data::{csv, infer::Inferrer, RowSource};
let mut rows = csv::CsvReader::new()
.read("service,p99,up\nweb,120,true\napi,35.5,false\n")
.unwrap();
assert_eq!(rows.columns(), ["service", "p99", "up"]);
// Types are only inferred when asked, and every guess carries its evidence.
let inference = Inferrer::new().infer(&rows);
assert_eq!(inference.columns()[1].data_type().to_string(), "float");
assert_eq!(inference.columns()[1].evidence().floats, 2);
inference.apply(&mut rows);
let console = Console::builder().width(40).build();
let out = console.render_export(&rows.to_table_data());
assert!(out.contains("│ api │ 35.5 │ false │"));Modules§
- arrow
- Arrow
RecordBatches as rows, and Arrow schemas in the format-neutral model (thearrowfeature). - csv
- CSV and TSV: a port of Python’s
csvsniffer and reader, and aCsvReaderthat turns a file intoRows. - er
- ER diagrams from the schema model (#247), behind the
erfeature. - infer
- Column type inference (#267), on request and with its evidence.
- jsonl
- JSON Lines: one JSON value per line, as rows.
- profile
- Data profiles (#343, #344, #345, #346): what every column of a CSV, JSON
Lines or any other
RowSourceholds, in one bounded pass. - quality
- Data quality results (#269): a check-result model and a report that
renders it the way
rich_ext’s test report renders test runs. - serialize
- Rows from any
serde::Serializevalues: a struct’s fields (or a map’s keys) are columns, and any other value is onevaluecolumn. - sql
- SQL-shaped result sets (#235): a query’s rows as a database shell shows them.
- stats
- Column statistics (#261): count, nulls, distinct values, min, max, mean, median, quantiles and the most common values, per column.
- window
- Windows of rows for
rich_ext’s virtualised tables (#260).
Structs§
- Data
Error - Why rows could not be read: what went wrong, and where when the source knows (a 1-based line or record number).
- Field
- One named field: a type, whether it may be null and whether it must be present, its constraints, and optionally the source’s own name for the type, a description and metadata.
- Record
Source - Rows from a stream of JSON records.
- Rows
- Rows held in memory: column names, an optional schema, and the rows.
- Rows
Source Rowsas aRowSource, fromRows::into_source.- Schema
- An ordered list of top-level fields, optionally named (a table, a
record type, a document), and the further tables a schema of several
holds (SQL DDL’s
CREATE TABLEs).
Enums§
Traits§
- RowSource
- The row source contract: column names, an optional schema, and rows.
Type Aliases§
- Row
- One row of cells.