# CSV::Reader (Class)

In: | csv.rb
Parent: | Object

DESCRIPTION

      CSV::Reader -- CSV formatted string/stream reader.

EXAMPLE

      Read CSV lines untill the first column is 'stop'.

      CSV::Reader.parse(File.open('bigdata', 'rb')) do |row|
        p row
        break if !row[0].is_null && row[0].data == 'stop'
      end

## Methods

close create each new parse shift

## Included Modules

Enumerable

## Public Class methods

create(str_or_readable, col_sep = ?,, row_sep = nil)

SYNOPSIS

      reader = CSV::Reader.create(str_or_readable)

ARGS

      str_or_readable: a CSV data to be parsed.  A String or an IO.

RETURNS

      reader: Created instance.

DESCRIPTION

      Create instance.  To get parse result, see CSV::Reader#each.

[Source]

    # File csv.rb, line 278
        def Reader.create(str_or_readable, col_sep = ?,, row_sep = nil)
          case str_or_readable
          when IO
            IOReader.new(str_or_readable, col_sep, row_sep)
          when String
            StringReader.new(str_or_readable, col_sep, row_sep)
          else
            IOReader.new(str_or_readable, col_sep, row_sep)
          end
        end

parse(str_or_readable, col_sep = ?,, row_sep = nil) {|row| ...}

SYNOPSIS

      CSV::Reader.parse(str_or_readable) do |row|
        ...
      end

ARGS

      str_or_readable: a CSV data to be parsed.  A String or an IO.
      row: a CSV::Row; an Array of a CSV::Cell in a line.

RETURNS

      nil

DESCRIPTION

      Parse CSV data and get lines.  Caller block is called for each line
      with an argument which is a chunk of cells in a row.

      Block value is always nil.  Rows are not cached for performance
      reason.

[Source]

    # File csv.rb, line 308
        def Reader.parse(str_or_readable, col_sep = ?,, row_sep = nil)
          reader = create(str_or_readable, col_sep, row_sep)
          reader.each do |row|
            yield(row)
          end
          reader.close
          nil
        end

new(dev)

[Source]

    # File csv.rb, line 376
        def initialize(dev)
          raise RuntimeError.new('Do not instanciate this class directly.')
        end

## Public Instance methods

each() {|row| ...}

SYNOPSIS

      CSV::Reader#each do |row|
        ...
      end

ARGS

      row: a CSV::Row; an Array of a CSV::Cell in a line.

RETURNS

      nil

DESCRIPTION

      Caller block is called for each line with an argument which is a chunk
      of cells in a row.

      Block value is always nil.  Rows are not cached for performance
      reason.

[Source]

    # File csv.rb, line 335
        def each
          while true
            row = Row.new
            parsed_cells = get_row(row)
            if parsed_cells == 0
              break
            end
            yield(row)
          end
          nil
        end

shift()

SYNOPSIS

      cell = CSV::Reader#shift

RETURNS

      cell: a CSV::Row; an Array of a CSV::Cell.

DESCRIPTION

      Extract cells of next line.

[Source]

    # File csv.rb, line 356
        def shift
          row = Row.new
          parsed_cells = get_row(row)
          row
        end

close()

SYNOPSIS

      CSV::Reader#close

RETURNS

      nil

DESCRIPTION

      Close this reader.

[Source]

    # File csv.rb, line 371
        def close
          terminate
        end

[Validate]