Function write_csv_typed

Source
pub fn write_csv_typed<P: AsRef<Path>>(
    path: P,
    data: &[Vec<DataValue>],
    headers: Option<&Vec<String>>,
    config: Option<CsvWriterConfig>,
) -> Result<()>
Expand description

Write typed data to a CSV file

§Arguments

  • path - Path to the output CSV file
  • data - Vector of vectors containing typed data values
  • headers - Optional column headers
  • config - Optional CSV writer configuration

§Returns

  • Result<()> - Success or error

§Examples

use scirs2_io::csv::{write_csv_typed, DataValue, CsvWriterConfig};

// Create mixed-type data
let row1 = vec![
    DataValue::String("Alice".to_string()),
    DataValue::Integer(25),
    DataValue::Float(168.5),
    DataValue::Boolean(true),
];
let row2 = vec![
    DataValue::String("Bob".to_string()),
    DataValue::Integer(32),
    DataValue::Float(175.0),
    DataValue::Boolean(false),
];

let data = vec![row1, row2];
let headers = vec![
    "Name".to_string(),
    "Age".to_string(),
    "Height".to_string(),
    "Active".to_string(),
];

write_csv_typed("typed_data.csv", &data, Some(&headers), None).unwrap();