use std::path::Path;
pub fn read_lines(path: &Path, sim_label: &str) -> Vec<Vec<f64>> {
let content = std::fs::read_to_string(path).unwrap_or_else(|e| {
panic!(
"Failed to read {sim_label} CSV from {}: {e}\n\
Generate with: docker run --rm -v $(pwd)/crates/astrodyn_verif_jeod/test_data:/output \
-v $(pwd)/trick/generate_references.sh:/generate_references.sh:ro jeod-trick",
path.display()
)
});
let path_display = path.display();
let mut rows = Vec::new();
for (i, line) in content.lines().enumerate() {
if i == 0 || line.trim().is_empty() {
continue;
}
let line_no = i + 1;
let row: Vec<f64> = line
.split(',')
.enumerate()
.map(|(col, s)| {
let token = s.trim();
let col_no = col + 1;
token.parse::<f64>().unwrap_or_else(|e| {
panic!(
"CSV parse error at {path_display}:{line_no}:{col_no} \
(sim {sim_label}): {token:?} — {e}"
)
})
})
.collect();
rows.push(row);
}
rows
}