Sha256: 6e2dd5d2f91df1ae389b8db6868bcca6025882214d15ff5593001792ee531f7b

Contents?: true

Size: 497 Bytes

Versions: 2

Compression:

Stored size: 497 Bytes

Contents

require 'csv'

module Chronicle
  module ETL
    class CSVLoader < Chronicle::ETL::Loader
      register_connector do |r|
        r.description = 'CSV'
      end

      def initialize(options={})
        super(options)
        @rows = []
      end

      def load(record)
        @rows << record.to_h_flattened.values
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chronicle-etl-0.4.1 lib/chronicle/etl/loaders/csv_loader.rb
chronicle-etl-0.4.0 lib/chronicle/etl/loaders/csv_loader.rb