Skip to main content

to_csv_list

Function to_csv_list 

Source
pub fn to_csv_list(doc: &Document, list_name: &str) -> Result<String>
Expand description

Convert a specific matrix list from a HEDL document to CSV string.

Exports only the specified named list to CSV format, with configurable header row and delimiter options. Nested children are skipped with a warning (logged as part of error handling if strict mode desired).

§Arguments

  • doc - The HEDL document
  • list_name - The name of the matrix list to export (e.g., “people”, “items”)

§Returns

A CSV-formatted string containing the specified list data

§Errors

Returns HedlError if:

  • The named list does not exist in the document
  • The list is not a MatrixList (i.e., it’s a scalar or object)
  • CSV serialization fails

§Example

use hedl_core::Document;
use hedl_csv::to_csv_list;

let doc = Document::new((1, 0));
let csv_string = to_csv_list(&doc, "people").unwrap();
println!("{}", csv_string);