Class: Uncsv
- Inherits:
-
Object
- Object
- Uncsv
- Includes:
- Enumerable
- Defined in:
- lib/uncsv.rb,
lib/uncsv/row.rb,
lib/uncsv/rows.rb,
lib/uncsv/config.rb,
lib/uncsv/header.rb,
lib/uncsv/version.rb,
lib/uncsv/key_normalizer.rb
Overview
Parses CSV data and iterates through it
Accepts a String
, IO
, or file, and outputs CSV rows. The rows can be
iterated over with each
. Uncsv
is also Enumerable
, so all of those
built-in Ruby methods also work with it, including map
, reduce
, select
,
etc.
Defined Under Namespace
Classes: Config, Header, KeyNormalizer, Row, Rows
Constant Summary collapse
- VERSION =
The current Uncsv library version
'1.0.0'
Class Method Summary collapse
-
.open(filename, opts = {}) {|config| ... } ⇒ Object
Create a new
Uncsv
parser from a file.
Instance Method Summary collapse
-
#each {|row| ... } ⇒ Enumerator
Iterate over each data row of the CSV.
-
#header ⇒ Array
Get an array of the headers.
-
#initialize(data, opts = {}) {|config| ... } ⇒ Uncsv
constructor
Create a new
Uncsv
parser.
Constructor Details
Class Method Details
.open(filename, opts = {}) {|config| ... } ⇒ Object
Create a new Uncsv
parser from a file
40 41 42 |
# File 'lib/uncsv.rb', line 40 def self.open(filename, opts = {}, &block) new(File.open(filename, 'rb'), opts, &block) end |
Instance Method Details
#each {|row| ... } ⇒ Enumerator
Iterate over each data row of the CSV
49 50 51 |
# File 'lib/uncsv.rb', line 49 def each(&block) rows.each(&block) end |
#header ⇒ Array
Get an array of the headers
Ordered from left to right
58 59 60 |
# File 'lib/uncsv.rb', line 58 def header rows.header end |