Function get_column_info

Source
pub fn get_column_info<S: AsRef<str> + PartialEq>(
    header: &[S],
    column: &S,
) -> Result<ColumnInfo>
Expand description

Function to get the column index for a given column name Returns an error if the column name is not found Typically ran using the header from the csv reader and is called inside the collect_column_info function to do this for each target column. Example:

use drug_extraction_cli::get_column_info;

let header = vec!["ID", "NAME", "DESCRIPTION"];
let column = "NAME";
let column_info = get_column_info(&header, &column);
assert!(column_info.is_ok());
let column_info = column_info.unwrap();
assert_eq!(column_info.name, "NAME");
assert_eq!(column_info.index, 1);