SixArm.com » Ruby » Spreadsheeting has import & export helpers for CSV, TSV, Excel, etc.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.yardoc
doc
lib
test
.codeclimate.yml
.document
.gemtest
.gitattributes
.gitignore
.rspec
.sha512.txt
.travis.yml
CHANGES.md
CONTRIBUTING.md
LICENSE.md
README.md
Rakefile
VERSION
sixarm_ruby_spreadsheeting-1.1.0-sha512.txt
sixarm_ruby_spreadsheeting-1.1.0.gem
sixarm_ruby_spreadsheeting-1.1.1.gem
sixarm_ruby_spreadsheeting.gemspec

README.md

SixArm.com → Ruby →
Spreadsheeting gem has import & export helpers for CSV, TSV, Excel, etc.

Introduction

String helpers for importing, exporting, and parsing spreadsheet data.

This is useful for reading and writing files in CSV, TSV, Excel, etc.

For docs go to http://sixarm.com/sixarm_ruby_spreadsheeting/doc

Want to help? We're happy to get pull requests.

Install

Gem

Run this command in your shell or terminal:

gem install sixarm_ruby_spreadsheeting

Or add this to your Gemfile:

gem 'sixarm_ruby_spreadsheeting'

Require

To require the gem in your code:

require 'sixarm_ruby_spreadsheeting'

Details

Some spreadsheet programs use cells that can have different types of data, such as:

  • a date like "2010/12/31"
  • a boolean flag like "+" or "-"
  • a freeform text note like "Hello"

This gem has methods for parsing and printing these individually and in combinations.

Example

Require:

require "sixarm_ruby_spreadsheeting"

To import a spreadsheet cell's text that may be a date or a freeform note:

date, note = import_date_or_note("2010/12/31") 
=> [<Date: 2010-12-31>, nil]

date, note = import_date_or_note("Hello") 
=> [nil, "Hello"]

To export either a date or a note to spreadsheet cell text:

date = Date.today
note = nil
export_date_or_note(date, text)  #=> "2010/12/31"

date = nil
note = "Hello"
export_date_or_note(date, text)  #=> "Hello"