Project

tabler

0.0
No commit activity in last 3 years
No release in over 3 years
Create csv data from an array of arrays of hashes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

tabler

Tabler generates csv from an array of hashes.

It will transform hashes with inconsistent keys into consistant csv tables.

Installation

gem install tabler

Usage

data = [
      { :col1 => "val 1", :col2 => "val 2"}, 
      { :col1 => "row 2 val 1", :col2 => "row 2 val 2"},
      { :col1 => "row 3 val 1", :col3 => "row 3 val 3", :col2 => "row 3 val 2"},
      { :col1 => "row 4 val 1", :col3 => "row 4 val 3" }
    ]

Tabler.generate(data, :col_sep => ";") # => Generate the csv string

The generated string from the example will look like:

col1;col2;col3
val 1;val 2;
row 2 val 1;row 2 val 2;
row 3 val 1;row 3 val 3;row 3 val 2
row 4 val 1;;row 4 val 3

Copyright

Copyright (c) 2012 Klaas Speller. See LICENSE for details.