Skip to content

Reading and writing of tabular data (parse and write CSV, TSV, fixed column width formats or any variation of those)

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

arjantop/rust-tabular

Repository files navigation

Tabular data reader/writer

Build Status

Reading and writing of tabular data.

  • DSV (Delimiter-separated values): CSV (comma-separated values), TSV (tab-separated values)
  • Fixed width: formats with columns of fixed width

Using the library

Add this to your Cargo.toml:

[dependencies.tabular]

git = "https://github.com/arjantop/rust-tabular.git"

Example

Reading CSV data:

use std::io::BufferedReader;
use std::io::File;

use tabular::dsv::{read_rows, CSV};

let path = Path::new("file.csv");
let mut file = BufferedReader::new(File::open(&path));
for row in read_rows(CSV, file) {
    println!("row = {}", row)
}

Reading fixed-length column data:

use std::io::BufferedReader;
use std::io::File;

use tabular::fixed::{Config, Newline, LF, ColumnConfig, Left, Right, read_rows};

let path = Path::new("file.csv");
let mut file = BufferedReader::new(File::open(&path));

let config = Config {
    columns: vec!(ColumnConfig {width: 5, pad_with: ' ', justification: Left},
                  ColumnConfig {width: 9, pad_with: '-', justification: Right}),
    line_end: Newline(LF)
};

for row in read_rows(config, file) {
    println!("row = {}", row)
}

Documentation

API documentation on rust-ci.org

Contributing

git clone https://github.com/arjantop/rust-tabular
cd rust-tabular
make

About

Reading and writing of tabular data (parse and write CSV, TSV, fixed column width formats or any variation of those)

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages