Skip to main content

export_measure_csv_to

Function export_measure_csv_to 

Source
pub fn export_measure_csv_to<W: Write>(
    model: &Model,
    measure: MeasureId,
    writer: W,
    delimiter: u8,
) -> Result<usize>
Expand description

Write a measure’s cells to writer as CSV/TSV (delimiter). Rows are written in coordinate order, so output is deterministic.

  • Input measure — writes model.inputs for that measure, unchanged.
  • Derived measure — runs improv_engine::dataflow::evaluate and writes the computed cells. An engine failure (cyclic/unsupported formula) is a CsvError::Other, not a silently empty file.

Error cells (#ERR, and the NaN the engine produces for a domain error like division by zero) are skipped, matching how input Value::Error cells have always been treated: the value column is typed, and writing #ERR/NaN into it would make the file fail to re-import as a Number column. The returned count reflects rows actually written, so a caller can see that skipping happened.

Text that a spreadsheet would run as a formula is neutralized; see ExportSpec::neutralize_formulas and export_measure_csv_with.