parse single channel more easily

This commit is contained in:
Tove 2026-02-18 22:29:31 +01:00
parent 7057563f82
commit 9cbcef89e5
2 changed files with 9 additions and 3 deletions

View file

@ -6,5 +6,6 @@ pkgs.mkShell {
rust-analyzer
cargo-watch
clippy
rustfmt
];
}

View file

@ -138,7 +138,7 @@ when using integrate mode, multiply may need to be set to a lower number.\
println!("infraconv: Interp = {}", params.interp);
let samples = interp(&samples, params.interp);
println!("infraconv: Samples = {}", samples.len());
let out_hz = (input_hz * params.speed * params.interp as f32).round() as i32;
@ -211,7 +211,8 @@ fn get_scale(samples: &[f64]) -> f64 {
fn read_csv(file: &str, channel: usize) -> Vec<f64> {
let csv = fs::read_to_string(file).expect("no existing input file provided");
csv.lines()
csv.trim()
.lines()
.filter(|line| line.contains(',') || !csv.contains(','))
.map(|line| {
let values = line.split(',');
@ -219,7 +220,11 @@ fn read_csv(file: &str, channel: usize) -> Vec<f64> {
.into_iter()
.map(|x| x.parse().unwrap())
.collect::<Vec<_>>();
values[channel]
if values.len() > 1 {
values[channel]
} else {
values[0]
}
})
.collect()
}