CsvUtil::CsvFileIterator Class Reference

The CsvFileIterator class allows CSV files to be iterated on a record basis. More...

Inheritance diagram for CsvUtil::CsvFileIterator:
[legend]

## Public Member Functions

| constructor (string path, *hash opts)
| Creates the CsvFileIterator in single-type mode with the path of the file to read and an option hash. More...
| constructor (string path, hash spec, hash opts)
| Creates the CsvFileIterator in multi-type mode with the path of the file to read and optionally an option hash. More...
private *string | getDataName ()
| Returns the name of the input data.
private string | getLineValueImpl ()
| Returns the current line trimmed of the EOL character(s)
private int | lineNumberImpl ()
| Returns the current line number.
private bool | nextLineImpl ()
| Moves the current line / record position to the next line / record; returns False if there are no more lines to iterate.
Public Member Functions inherited from CsvUtil::AbstractCsvIterator
| constructor (*hash opts)
| creates the AbstractCsvIterator with an option hash in single-type mode More...
| constructor (hash spec, hash opts)
| creates the AbstractCsvIterator with an option hash in multi-type mode More...
private *string | getDataName ()
| Returns the name of the input data.
*list | getHeaders ()
| Returns the current record headers or NOTHING if no headers have been detected or saved yet. More...
*list | getHeaders (string type)
| Returns a list of headers for the given record or NOTHING if the record is not recognized. More...
private list | getLineAndSplit ()
| Read line split by separator/quote into list.
string | getQuote ()
| Returns the current quote string. More...
hash | getRecord (bool extended)
| Returns the current record as a hash. More...
hash | getRecord ()
| Returns the current record as a hash. More...
any | getRecordList ()
| Returns the current record as a list. More...
string | getSeparator ()
| Returns the current separator string. More...
hash | getValue ()
| Returns the current record as a hash. More...
string | identifyType (list rec)
| Identify a fixed-length line type using identifyTypeImpl(); may be overridden if necessary. More...
private *string | identifyTypeImpl (list rec)

Identify a input record, given the raw line string. This method performs a lookup to a precalculated table based on number of records (see constructor()). In case different criteria are needed, eg. when two line types in a spec have the same record number and no unique resolving rule are specified, this method needs to be overridden, otherwise it will throw an exception because the precalculated mapping will be empty. More...

int | index ()
| Returns the row index being iterated, which does not necessarily correspond to the line number when there are header rows and blank lines are skipped. More...
int | lineNumber ()
| Returns the current iterator line number in the file (the first line is line 1) or 0 if not pointing at a valid element. More...
any | memberGate (string name)
| Returns the given column value for the current row. More...
bool | next ()
| Moves the current line / record position to the next line / record; returns False if there are no more lines to iterate. More...
private hash | parseLine ()
| Parses a line in the file and returns a processed list of the fields.
private | prepareFieldsFromHeaders (*list headers)
| match headers provided at Csv header or in options, never called for multi-type because header_names is False */
private | processCommonOptions (*hash opts, int C_OPTx)
| process common options and and assing internal fields
private | processSpec (hash spec)
| process specification and assing internal data for resolving

## Detailed Description

The CsvFileIterator class allows CSV files to be iterated on a record basis.

See also
  - AbstractCsvIterator Constructor Option Hash Overview
  - Option Field Types
  - Option Field Hash

## Member Function Documentation

CsvUtil::CsvFileIterator::constructor | ( | string | path,
|  | *hash | opts
| ) |  |

Creates the CsvFileIterator in single-type mode with the path of the file to read and an option hash.

Parameters

  path | the path to the CSV file to read
  opts | a hash of optional options; see AbstractCsvIterator Constructor Option Hash Overview for more information

Exceptions

  ABSTRACTCSVITERATOR-ERROR | invalid or unknown option; invalid data type for option; `"header_names"` is True and `"header_lines"` is 0 or `"headers"` is also present; unknown field type

CsvUtil::CsvFileIterator::constructor | ( | string | path,
|  | hash | spec,
|  | hash | opts
| ) |  |

Creates the CsvFileIterator in multi-type mode with the path of the file to read and optionally an option hash.

Parameters

  path | the path to the CSV file to read
  spec | a hash of field and type definition; see Option Field Hash for more information
  opts | a hash of optional options; see AbstractCsvIterator Constructor Option Hash Overview for more information