use matten_data::{MattenDataError, Table};
fn main() -> Result<(), MattenDataError> {
let csv = "\
region,sales,cost
north,100,40
south,150,
east,120,55";
let table = Table::from_csv_str(csv)?;
let numeric_cols = table.select_columns(["sales", "cost"])?;
match numeric_cols.try_numeric() {
Err(MattenDataError::MissingValue { column, row }) => {
println!("missing value blocked conversion: column={column}, csv_line={row}");
assert_eq!(column, "cost");
assert_eq!(row, 3); }
other => panic!("expected MissingValue, got {other:?}"),
}
let tensor = numeric_cols.fill_missing(0.0)?.try_numeric()?.to_tensor()?;
println!("filled shape: {:?}", tensor.shape());
println!("filled data : {:?}", tensor.as_slice());
assert_eq!(tensor.shape(), &[3, 2]);
assert_eq!(tensor.as_slice(), &[100.0, 40.0, 150.0, 0.0, 120.0, 55.0]);
println!("data_03_missing_values: OK");
Ok(())
}