Provide lightweight tabular data structures and utilities
Source: target-root/usr/local/lib/solidgroundux/common/sgnd-datatable.sh
Provide lightweight tabular data structures and utilities
Public functions
- Return the number of elements in a named indexed array.
- Split a pipe-delimited schema into its column names.
- Split a PSV row into fields, preserving trailing empty fields.
- Reject values that cannot be safely stored in a PSV row.
- Validate a pipe-delimited schema for nonempty unique column names.
- Look up the zero-based index of a named schema column.
- Count the columns in a pipe-delimited schema.
- Join values into a validated PSV row in schema order.
- Test whether any row matches a column value.
- Extract one named column from an already obtained PSV row.
- Return a PSV row with one named field replaced.
- Count the rows stored in a named table array.
- Append an already formatted PSV row to a table array.
- Delete a row and compact its table array.
- Read a column from a table row by numeric index.
- Update a named column in a table row by numeric index.
- Find the first row whose named column equals a value.
- Build, validate and append a row from individual field values.
- Render table rows with an aligned heading and themed colors.
- Return table rows sorted by one or more named columns.
- Expand a PSV row into prefixed shell variables.
- Write a table to a PSV file with the schema as its first line.
Internal functions
| Function | Purpose | Arguments | Output |
|---|---|---|---|
_sgnd_lib_guard | Ensure direct execution is rejected and record that the library has been sourced. | — | — |
_dt_build_sortkey | Build a case-insensitive sort key from a row. | - $1 — Schema containing the named columns. | Prints the lowercased field values joined by \ |
Description
Provides a lightweight, schema-driven datatable abstraction for handling structured data within shell scripts.
The library:
- Defines schema-based row structures using delimited fields
- Stores and manages tabular data in indexed arrays
- Supports row insertion, retrieval, and iteration
- Enables field-based access using schema definitions
- Provides helper functions for filtering and transformation
Design principles
- Minimal abstraction on top of native shell arrays
- Schema-driven access for readability and consistency
- Predictable and explicit data handling
- Lightweight implementation without external dependencies
Role in framework
- Core data structure used across SolidGroundUX tooling
- Backbone for metadata parsing, UI rendering, and data exchange
Non-goals
- Full relational data modeling or query capabilities
- Persistent storage or database functionality
- Replacement for external data processing tools
