Sha256: 09c696a520adc9bfe87c226750eb9ff2475bff80b02126b61911d7a58ed6b897

Contents?: true

Size: 493 Bytes

Versions: 4

Compression:

Stored size: 493 Bytes

Contents

require 'csv'

module Chronicle
  module ETL
    class CsvLoader < Chronicle::ETL::Loader
      def initialize(options={})
        super(options)
        @rows = []
      end

      def load(result)
        if (result.is_a? Hash)
          @rows << result.values
        else
          @rows << result
        end
      end

      def finish
        z = $stdout
        CSV(z) do |csv|
          @rows.each do |row|
            csv << row
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chronicle-etl-0.2.3 lib/chronicle/etl/loaders/csv_loader.rb
chronicle-etl-0.2.2 lib/chronicle/etl/loaders/csv_loader.rb
chronicle-etl-0.2.1 lib/chronicle/etl/loaders/csv_loader.rb
chronicle-etl-0.2.0 lib/chronicle/etl/loaders/csv_loader.rb