Sha256: dcc9fdf9027ee0f758e250747ae5e055cb4592731fe3c7db92dc0c5990019b67

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 Bytes

Contents

require 'csv'

module Itiel
  module Extract
    #
    # Extracts all specified CSV file rows and sends it in batches to
    # its next step
    #
    # Usage:
    #
    #    csv_file            = Itiel::Extract::CSVFile.new('FileName.csv')
    #    csv_file.batch_size = 15
    #    csv.file.start
    #
    class CSVFile
      include ChainedStep
      include Itiel::Nameable

      attr_accessor :file_name

      def initialize(file_name)
        self.file_name = file_name
      end

      def extract
        lines = CSV.read(self.file_name, :headers => true)
        lines.collect(&:to_hash)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
itiel-0.1.2 lib/itiel/extract/csv_file.rb
itiel-0.1.1 lib/itiel/extract/csv_file.rb
itiel-0.1.0 lib/itiel/extract/csv_file.rb