Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Generate csv from an array of hashes
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
Gemfile
LICENSE
README.md
Rakefile
tabler.gemspec

README.md

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.

Something went wrong with that request. Please try again.