satellitesfactory 0.0.3

Satellite factory — classify, build and catalogue natural satellites for any planetary system: Solar System moons (Moon, Galileans, Titan, Triton…) or custom configurations.
Documentation
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(())
}