Hi,
I encountered a problem to parse a CSV file
As I am new to Rust, I don't know what to after getting a StringRecord from a line of my cvsfile and put it into a Struct
Didier
struct Protocol {
id: i32,
protocol_number: String,
description: String,
prefix: String,
in_progress: bool,
validity_date : String,
expiration_date : String,
customer_base : bool,
contract_provision_file : String,
guarranty : String,
other_document : String,
alert_message : String
}
pub fn example() {
let _rdr = match ReaderBuilder::new()
.has_headers(false)
.delimiter(b';')
.from_path("myapp_protocol.csv"){
Ok( mut _rdr) => {
for result in _rdr.records()
{
match result {
Ok (r) => {
//let record = &r;
println!("record {:?} len {}", &r,&r.len());
println!("", )
}
Err (e) => {
println!("{:?}", e);
}
}
}
}
Err(e) => {
// Il y a eu un problème, affichons l'erreur pour voir ce qu'il se passe
println!("{}", e);
}
};
}