All Projects → BurntSushi → Rust Csv

BurntSushi / Rust Csv

Licence: other
A CSV parser for Rust, with Serde support.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rust Csv

Ta Rs
Technical analysis library for Rust language
Stars: ✭ 248 (-72.78%)
Mutual labels:  library, rust-library
Grammers
(tele)gramme.rs - use Telegram's API from Rust
Stars: ✭ 109 (-88.04%)
Mutual labels:  library, rust-library
Atty
are you or are you not a tty?
Stars: ✭ 153 (-83.21%)
Mutual labels:  library, rust-library
Kbcsv
KBCsv is an efficient, easy to use .NET parsing and writing library for the CSV (comma-separated values) format.
Stars: ✭ 75 (-91.77%)
Mutual labels:  csv, library
Csv2ofx
A Python library and command line tool for converting csv to ofx and qif files
Stars: ✭ 133 (-85.4%)
Mutual labels:  csv, library
Criterion
Microbenchmarking for Modern C++
Stars: ✭ 140 (-84.63%)
Mutual labels:  csv, library
Dumpling
Dumpling is a fast, easy-to-use tool written by Go for dumping data from the database(MySQL, TiDB...) to local/cloud(S3, GCP...) in multifarious formats(SQL, CSV...).
Stars: ✭ 134 (-85.29%)
Mutual labels:  csv, library
Meza
A Python toolkit for processing tabular data
Stars: ✭ 374 (-58.95%)
Mutual labels:  csv, library
Xsv
A fast CSV command line toolkit written in Rust.
Stars: ✭ 7,831 (+759.6%)
Mutual labels:  csv
Eglo
EGL/X11 Abstraction Library for Pocket C.H.I.P
Stars: ✭ 15 (-98.35%)
Mutual labels:  library
Timesheet.js
JavaScript library for HTML5 & CSS3 time sheets
Stars: ✭ 6,881 (+655.32%)
Mutual labels:  library
Cordova Plugin Camera
Apache Cordova Plugin camera
Stars: ✭ 879 (-3.51%)
Mutual labels:  library
Serf
Mirror of Apache Serf
Stars: ✭ 15 (-98.35%)
Mutual labels:  library
Androidlibs
🔥正在成为史上最全分类 Android 开源大全~~~~(长期更新 Star 一下吧)
Stars: ✭ 7,148 (+684.63%)
Mutual labels:  library
Ambient
Lightweight ambient light javascript library for HTML image and video elements
Stars: ✭ 20 (-97.8%)
Mutual labels:  library
Omgl
Pythonic OpenGL Bindings
Stars: ✭ 13 (-98.57%)
Mutual labels:  library
Printcess
Haskell pretty printing library supporting indentation, mixfix operators, and automatic line breaks.
Stars: ✭ 13 (-98.57%)
Mutual labels:  library
Honeyjs
An open source Javascript Honey Pot implementation
Stars: ✭ 20 (-97.8%)
Mutual labels:  library
Humblelogging
HumbleLogging is a lightweight C++ logging framework. It aims to be extendible, easy to understand and as fast as possible.
Stars: ✭ 15 (-98.35%)
Mutual labels:  library
Breadcast
Small Broadcast Receiver Library for Android
Stars: ✭ 15 (-98.35%)
Mutual labels:  library

csv

A fast and flexible CSV reader and writer for Rust, with support for Serde.

Linux build status Windows build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/csv

If you're new to Rust, the tutorial is a good place to start.

Usage

Add this to your Cargo.toml:

[dependencies]
csv = "1.1"

Example

This example shows how to read CSV data from stdin and print each record to stdout.

There are more examples in the cookbook.

use std::error::Error;
use std::io;
use std::process;

fn example() -> Result<(), Box<dyn Error>> {
    // Build the CSV reader and iterate over each record.
    let mut rdr = csv::Reader::from_reader(io::stdin());
    for result in rdr.records() {
        // The iterator yields Result<StringRecord, Error>, so we check the
        // error here.
        let record = result?;
        println!("{:?}", record);
    }
    Ok(())
}

fn main() {
    if let Err(err) = example() {
        println!("error running example: {}", err);
        process::exit(1);
    }
}

The above example can be run like so:

$ git clone git://github.com/BurntSushi/rust-csv
$ cd rust-csv
$ cargo run --example cookbook-read-basic < examples/data/smallpop.csv

Example with Serde

This example shows how to read CSV data from stdin into your own custom struct. By default, the member names of the struct are matched with the values in the header record of your CSV data.

use std::error::Error;
use std::io;
use std::process;

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Record {
    city: String,
    region: String,
    country: String,
    population: Option<u64>,
}

fn example() -> Result<(), Box<dyn Error>> {
    let mut rdr = csv::Reader::from_reader(io::stdin());
    for result in rdr.deserialize() {
        // Notice that we need to provide a type hint for automatic
        // deserialization.
        let record: Record = result?;
        println!("{:?}", record);
    }
    Ok(())
}

fn main() {
    if let Err(err) = example() {
        println!("error running example: {}", err);
        process::exit(1);
    }
}

The above example can be run like so:

$ git clone git://github.com/BurntSushi/rust-csv
$ cd rust-csv
$ cargo run --example cookbook-read-serde < examples/data/smallpop.csv
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].