Hi,

here's a quick patch that could be useful to others. I had that need to use
the file destination to output a CSV file (with the headers included so that
another process can reliably import it on another machine later on).

Syntax:

destination :out, { :file => output_file, :include_headers => true, :enclose
=> '"', :separator => ";" }, { :order => target_fields }

cheers,

Thibaut

Index:
vendor/activewarehouse-etl/lib/etl/control/destination/file_destination.rb
===================================================================
---
vendor/activewarehouse-etl/lib/etl/control/destination/file_destination.rb
(revision 765)
+++
vendor/activewarehouse-etl/lib/etl/control/destination/file_destination.rb
(working copy)
@@ -35,6 +35,7 @@
       # * <tt>:enclose</tt>: Enclosure character (default is none)
       # * <tt>:unique</tt>: Set to true to only write unique records
       # * <tt>:append_rows</tt>: Array of rows to append
+      # * <tt>:include_headers</tt>: Set to true to output the headers as
the first row (based on :order)
       #
       # Mapping options:
       # * <tt>:order</tt>: The order array
@@ -49,6 +50,8 @@

         @order = mapping[:order] || order_from_source
         raise ControlError, "Order required in mapping" unless @order
+
+        write(has...@order.zip(@order).flatten]) if
configuration[:include_headers] == true
       end

       # Close the destination. This will flush the buffer and close the
underlying stream or connection.

Thibaut Barrère
--
LoGeek
[tel] +33 6 85 33 40 88
[mail] thibaut.barr...@gmail.com
[blog] http://evolvingworker.com - tools for a better day
[blog] http://blog.logeek.fr - about writing software
_______________________________________________
Activewarehouse-discuss mailing list
Activewarehouse-discuss@rubyforge.org
http://rubyforge.org/mailman/listinfo/activewarehouse-discuss

Reply via email to