use std::io::Write;
pub fn write_csv(path: &str, headers: &[&str], rows: &[Vec<f64>]) -> std::io::Result<()> {
let mut f = std::fs::File::create(path)?;
writeln!(f, "{}", headers.join(","))?;
for row in rows {
let line: Vec<String> = row.iter().map(|v| format!("{:.6e}", v)).collect();
writeln!(f, "{}", line.join(","))?;
}
Ok(())
}
pub fn write_dat(path: &str, headers: &[&str], rows: &[Vec<f64>]) -> std::io::Result<()> {
let mut f = std::fs::File::create(path)?;
writeln!(f, "# {}", headers.join("\t"))?;
for row in rows {
let line: Vec<String> = row.iter().map(|v| format!("{:.6e}", v)).collect();
writeln!(f, "{}", line.join("\t"))?;
}
Ok(())
}