none
How to keep headers in output?

    Question

  • There was headers in original input file, but it was filtered out so that it that not ruin calculation.

    How to keep headers of column like "CustomerId" and add it to ouput? Following code is otherwise working fine.

    //CODE 
    DECLARE @in  string = "/Input/CustomerSalesDataLake.csv";
    DECLARE @out string = "/Output/CustomerSalesDataLakeOutput.csv";

    @log =
        EXTRACT  CustomerId         string,
                 CustomerName          string,
                 Sales string,
                 TimeStamp string
      FROM @in
      USING Extractors.Text(delimiter:';', quoting:false);


    @query =
        SELECT 
          CustomerId,
          CustomerName,
          AVG(float.Parse(Sales, CultureInfo.InvariantCulture)) AS Sales,
          DateTime.Parse(TimeStamp).Month AS Date
      FROM @log
      WHERE TimeStamp != "DateTime"
      GROUP BY CustomerId, CustomerName, TimeStamp;
    OUTPUT @query   
        TO @out
        USING Outputters.Csv();

    //  File content------------------------------
    //  "/Input/CustomerSalesDataLake.csv";
    //  CustomerId CustomerName Sales DateTime
    //  1 Ford 4,17 2016-12-05T13:08:30.044Z
    //  2 Nissan 7,90 2016-12-05T13:08:30.044Z

    // File content------------------------------
    // "/Output/CustomerSalesDataLakeOutput.csv";
    //"1","Ford",417,12
    //"2","Nissan",790,12


    Kenny_I

    Tuesday, December 20, 2016 10:07 AM

Answers