parse single channel more easily
This commit is contained in:
parent
7057563f82
commit
9cbcef89e5
2 changed files with 9 additions and 3 deletions
|
|
@ -6,5 +6,6 @@ pkgs.mkShell {
|
|||
rust-analyzer
|
||||
cargo-watch
|
||||
clippy
|
||||
rustfmt
|
||||
];
|
||||
}
|
||||
|
|
|
|||
11
src/main.rs
11
src/main.rs
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue