pub fn parse_columns<T, F>(
input: T,
column: usize,
delimiter: &str,
f: F,
) -> Result<()>
Expand description
Parse columns from the given input
& delimiter
, passing the resulting
column into the provided closure. The closure can be used to process
the column value:
// Accumulate the values
use pc_rs::parse_columns;
let input = "1 2 3 4\na b c d";
let input = Box::new(std::io::BufReader::new(input.as_bytes()));
let mut results = Vec::new();
parse_columns(input, 1, " ", |col| results.push(col.to_owned())).unwrap();
assert_eq!(&results, &["1", "a"]);
// Print values
use pc_rs::parse_columns;
let input = "1 2 3 4\na b c d";
let input = Box::new(std::io::BufReader::new(input.as_bytes()));
parse_columns(input, 1, " ", |col| println!("{col}")).unwrap();