Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Looking for best way to pass Transform Stream Fields into a Commd line arguement?

  1. #1

    Question Looking for best way to pass Transform Stream Fields into a Commd line arguement?

    All -

    I want to execute a simple command line for every row (Windows). I have Excel Input step and I want to run the following command for fields in stream:

    mposter -b "Priority=<Priority_Field>;StatusModel=<StatusModel_Field>;Category=<Category_Field>;Company=<Company_Field>.."

    What is the best way to do this? I have looked at using Execute a Process step, but how can I pass in a large number of fields? Can someone share a simple script that I re-use as an example?

    Thanks in advance!

    KP

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

    Default

    What I have done (but does not mean that's the only way):
    1. In a job J1, create a transformation T1 with Excel Input file and Copy Rows to result and link T1 to a Job J2
    2. In J2, select option to run for each row
    3. Within J2 create a transformation with Get rows and a text file output - create text file with ONE filed and no Header (fields names) which is my .bat file (NOTE: you probably need a step or two to create the correct batch line)
    2. In J1, link J2 to a Shell step and point it to the batch file just created.

    I'm writing this by memory, so maybe you need to tweak a bit!
    -- Mick --

  3. #3
    Join Date
    Nov 2008
    Posts
    777

    Default

    I usually use a JavaScript step to either perform simple concatenation of all the command string parts or else define a template string with placeholders and then replace them with the field values. At that point, the command string can be passed to an Execute A Process step.
    pdi-ce-4.4.0-stable
    Java 1.7 (64 bit)
    MySQL 5.6 (64 bit)
    Windows 7 (64 bit)

  4. #4

    Default

    Darrell -

    This worked. Here is a screenshot of my transform and working as you suggested:

    Name:  Tranform.jpg
Views: 18
Size:  16.9 KB

    Question ... I notice that if I have a Blank or NULL value in any field, then the command hangs. Is there a step that can used at a GLOBAL level for any field that is NULL, just put in 'n/a'? I believe we can do that with specifying individual fields.

    Let me know.

    KP

  5. #5
    Join Date
    Nov 2008
    Posts
    777

    Default

    Quote Originally Posted by karlis_peterson View Post
    Is there a step that can used at a GLOBAL level for any field that is NULL, just put in 'n/a'?
    Try inserting an "If field value is null" step along the way. The step is under the "Utility" group in Spoon.
    pdi-ce-4.4.0-stable
    Java 1.7 (64 bit)
    MySQL 5.6 (64 bit)
    Windows 7 (64 bit)

  6. #6

    Default

    Darrell -

    AWESOME! That worked perfectly!

    Thank you for the hints here.

    KP

Tags for this Thread

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.