Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages