Skip to main content

Module csv_wizard

Module csv_wizard 

Source
Expand description

CSV/TSV import/export wizard: form state + pure spec-building for the GUI panel (rendered by ImprovApp::csv_import_ui/csv_export_ui in app.rs). Mirrors the CLI’s import-csv/export-csv semantics (delimiter auto-detected from the .tsv extension unless overridden; item_id_base set high enough to avoid colliding with hand-assigned ids — see crates/cli/src/main.rs::cmd_import_csv/cmd_export_csv) so the wizard behaves exactly like improv import-csv/export-csv.

Kept free of any egui::Ui parameter so build_import_spec/ build_export_args/detect_delimiter are unit-tested without a window; the actual widgets live in app.rs, which owns ImprovApp’s state.

Structs§

DimRow
One dimension-mapping row in the import form: a CSV/TSV column, and the category it becomes (id + name). All three fields are free text, parsed on submit by build_import_spec.
ExportForm
The export wizard’s form state.
ImportForm
The import wizard’s editable form state. Mirrors the CLI’s import-csv arguments (see crates/cli/src/main.rs::cmd_import_csv).

Constants§

ITEM_ID_BASE 🔒
Base id for minting item ids on import — high enough to avoid colliding with hand-assigned ids (matches the CLI’s cmd_import_csv).

Functions§

build_export_args
Resolve the export form into (measure, path, delimiter). Pure: no egui, no I/O; improv_storage_csv::export_measure_csv does the real work.
build_import_spec
Build an ImportSpec from the wizard’s form fields. Validates as the CLI does: a non-empty path, a numeric measure id, a non-empty measure name and value column, and at least one fully-filled dimension row (a blank spacer row — all three fields empty — is skipped, not an error). Pure: no egui, no I/O; improv_storage_csv::import_csv does the real work.
column_ref 🔒
A column reference: a 0-based index when there’s no header row, else a header name (mirrors the CLI’s col_ref closure).
detect_delimiter
The delimiter for path: TSV if tsv_checked or the path ends in .tsv, else CSV. Matches the CLI’s --tsv/extension convention exactly.