A CSV parser written in Rust with nom
Rust
Switch branches/tags
Nothing to show
Clone or download
Latest commit e070a3e Nov 16, 2016
Permalink
Failed to load latest commit information.
src Remove invalid printing Nov 16, 2016
Cargo.toml Use nom 1.1 Jan 8, 2016
LICENSE Initial commit Sep 7, 2015
README.md Add error handling, improve README file Jan 7, 2016

README.md

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!
    }
}