expression

Configure a CSV delimiter

Specify a delimiter for the file dialect rather than splitting lines manually. A delimiter is a byte; quoted fields may contain it. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 2 a;b Common mistake: Splitting a quoted CSV field at every delimiter.

Formal Syntax & Structure

rust syntaxrust
csv::ReaderBuilder::new().delimiter(b';').from_reader(input)

Working Example

Example Snippetrust
fn main() {    let mut r = csv::ReaderBuilder::new().delimiter(b';').from_reader(&b"name;note\nbook;\"a;b\"\n"[..]);    let row = r.records().next().unwrap().unwrap();    println!("{} {}", row.len(), &row[1]);}
Rust Reference