GuillaumeGomez / csv-parser

A CSV parser written in Rust with nom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

csv-parser

A CSV parser written in Rust with nom.

##HOWTO

This library provides 3 functions:

  • parse_csv
  • parse_csv_from_file
  • parse_csv_from_slice

They all return a Result containing a vector of vector. The first line of the vector contains each column name.

##Examples

A short one:

use csv_parser;

fn main() {
    let csv_to_parse = "\"nom\",age\ncarles,30\nlaure,28\n";
    if let Ok(parsed_csv) = parse_csv(csv_to_parse) {
        // and we're all good!
    }
}

You can give a file path as well:

use csv_parser;

fn main() {
    let csv_file = "some_file.csv";
    if let Ok(parsed_csv) = parse_csv_from_file(csv_file) {
        // and we're all good!
    }
}

About

A CSV parser written in Rust with nom

License:MIT License


Languages

Language:Rust 100.0%