CSV::IOReader (Class)

In: csv.rb
Parent: Reader

DESCRIPTION

  CSV::IOReader -- CSV formatted 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

Public Class methods

SYNOPSIS

  reader = CSV::IOReader.new(io)

ARGS

  io: a CSV data to be parsed.  Must be an IO. (io#read is called.)

RETURNS

  reader: Created instance.

DESCRIPTION

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

[Source]

# File csv.rb, line 464
    def initialize(io, col_sep = ?,, row_sep = nil)
      @io = io
      @io.binmode if @io.respond_to?(:binmode)
      @col_sep = col_sep
      @row_sep = row_sep
      @dev = CSV::IOBuf.new(@io)
      @idx = 0
      if @dev[0] == 0xef and @dev[1] == 0xbb and @dev[2] == 0xbf
        @idx += 3
      end
      @close_on_terminate = false
    end

Public Instance methods

SYNOPSIS

  CSV::IOReader#close_on_terminate

RETURNS

  true

DESCRIPTION

  Tell this reader to close the IO when terminated (Triggered by invoking
  CSV::IOReader#close).

[Source]

# File csv.rb, line 487
    def close_on_terminate
      @close_on_terminate = true
    end

[Validate]