xls-rs 0.1.7

Rust spreadsheet CLI, library, and MCP server for reading, writing, converting, and analyzing XLSX, XLS, CSV, ODS, Parquet, and Avro with pandas-style operations.
Documentation
//! Data profiling command handler

use xls_rs::{converter::Converter, profiling::DataProfiler};
use anyhow::{Context, Result};

/// Handle the profile command
///
/// Generates a data profile report.
pub fn handle_profile(input: String, output: Option<String>) -> Result<()> {
    let converter = Converter::new();
    let data = converter.read_any_data(&input, None)?;

    let profiler = DataProfiler::new();
    let profile = profiler.profile(&data, &input)?;

    let report = serde_json::to_string_pretty(&profile)?;

    if let Some(output_path) = output {
        std::fs::write(&output_path, report)
            .context(format!("Failed to write profile to {output_path}"))?;
        println!("Profile saved to {}", output_path);
    } else {
        println!("{}", report);
    }

    Ok(())
}