oocsv

A very dynamic object-oriented approach to CSV reading and writing.

Installation

RubyGems

$ gem install oocsv

Bundler

Add this line to the application's Gemfile:

gem('oocsv')

And then execute:

$ bundle

Usage

require 'oocsv'

str = <<EOF
Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38
EOF
# => "Year,Make,Model,Length\n1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38\n"

ary = OOCSV.read(str)
# => [#<struct Struct::CSVEntry>, #<struct Struct::CSVEntry>]

print OOCSV.write(ary)
# Year,Make,Model,Length
# 1997,Ford,E350,2.34
# 2000,Mercury,Cougar,2.38

ary[0].to_s
# => "#<struct Struct::CSVEntry @Year=1997 @Make=Ford @Model=E350 @Length=2.34>"