Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Create Rows in JavaScript

  1. #1
    Join Date
    Jan 2014
    Posts
    1

    Default Create Rows in JavaScript

    Hello! i'm new here!
    I dont know why my code dont work:

    Code:
    var fi = Fecha_Inicio;
    while (fi<=Fecha_Termino)
    {
       newRow = createRowCopy(getOutputRowMeta().size());
       var rowIndex = getInputRowMeta().size();
       newRow[rowIndex++] = fi;
       newRow[rowIndex++] = "N";
       putRow(newRow);
       dateAdd(fi,"d",1); 
    }
    var Fecha = "";
    var ignore = "Y";
    I'm triying to create multiple rows from a range of two dates.

    Example:

    Input Data:

    ID Fecha_Inicio Fecha_Termino
    1 10/12/2013 12/12/2013


    ->The date (Fecha_Inicio and Fecha_Termino) are in dd/mm/yyyy

    Output Data:

    ID Fecha_Inicio Fecha_Termino Fecha
    1 10/12/2013 12/12/2013 10/12/2013
    1 10/12/2013 12/12/2013 11/12/2013
    1 10/12/2013 12/12/2013 12/12/2013


    What is wrong with my code? How Can I do that?

    Thanks!
    Greetings!

  2. #2
    Join Date
    Apr 2008
    Posts
    1,771

    Default

    I would use a cartesian join step.
    http://wiki.pentaho.com/display/EAI/...ian+product%29
    -- Mick --

  3. #3
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Quote Originally Posted by nceroni View Post
    What is wrong with my code?
    Well, spot the difference

    Code:
    index = getInputRowMeta().size();
    runDate = Fecha_Inicio;
    while (dateDiff(runDate, Fecha_Termino, "d") > 0)
    {
        newRow = createRowCopy(getOutputRowMeta().size());
        newRow[index] = runDate;
        putRow(newRow);
        runDate = dateAdd(runDate, "d", 1);
    }
    var Fecha = runDate;
    Quote Originally Posted by nceroni View Post
    How Can I do that?
    You should do it the Kettle way, i.e. with minimum scripting.
    Attached Files Attached Files
    So long, and thanks for all the fish.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.