renato-zannon / rust-csv

A CSV parser for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing CSV in Rust

Build Status

This parser is a rewrite, different from the original rust-csv, because the previous project used an old syntax. For a failed attempt to update it to current Rust, see rust-csv-legacy

    use csv;
    use std::io::MemReader;

    fn main() {
      let s = "a;b;c;d\r\ne;f;g;h";

      let reader = MemReader::new(Vec::from_slice(s.as_bytes()));
      let mut parser = csv::init(reader);

      //default delimitor is ','
      parser.delim(';');

      for row in parser {
        println!("first element is: {}", row.get(0));
      }
    }

Installation

    $ rustpkg install github.com/Geal/rust-csv

Unit testing

Clone the project, and in its repository:

    $ rustpkg build csv && rustpkg test csv

About

A CSV parser for Rust


Languages

Language:Rust 100.0%