Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: pass information in variables

  1. #1
    Join Date
    Mar 2011
    Posts
    2

    Default pass information in variables

    Hello guys!

    First I have to say, that my english is very bad, nevertheless I hope you can help me with my “data operations” J

    I Just have create a script which execute some simple file operations. It is not that difficult to realize it in Windows Powershell which I have already done.
    But the problem is that the script has just over 200 lines and is very confusing for other people, if they are trying to figure out what the script does.
    So, I decided to realize it more “visually” which brought me to Kettle. (this sentence is strange, I know ^^)


    I just want to do something like this:

    1. Get subfolders of folder C:\test
    2. Save the delivered information (with the “folder-objects”) in an array/file that I can handle them.
    3. Move files to another location´
    4. Etc.


    In powershell you could realize it like this:

    Code:
    $folders = Get-Childitem “c:\test”
      Foreach ($file in $folders)
      {
              Move-item $file –destination “C:\output”
      }
    Now the question is, how can I realize it in Kettle, especially how can I save Information in variables and hand it over to other operations like zipping, moving, or renaming.

    Hopefully, you can understand what I am trying to say L

    I would be glad for some help!

    Thank you very much!

    Best regards

  2. #2
    Join Date
    Mar 2006
    Posts
    170

    Default

    Hi,

    Not sure why you need to keep any of the info in vars.

    What you are describing is easy to do.

    You'll probably need to have a Job that calls a Transformation or two.

    Some of what you need is done in a Trans like getting the files and folders under C:\test ... then passed back into the Job where your file operations like zipping and moving will take place.

    Regardless, it can all be done.

    Start messing around.

    You don't need vars but you can create and populate them if you wish. You will see that much like a script PDI has you do "something" which usually returns info .. which is then added to the stream. That info within the stream is ready to be worked on by other stuff.

    Good Luck!

    Kent

  3. #3
    Join Date
    Apr 2009
    Posts
    12

    Default

    Would be so helpful to have an example. I'm trying to use the filenames returned by the get filenames step in other transformation. Don't know how to get each filename out of the stream.

  4. #4
    Join Date
    Mar 2006
    Posts
    170

    Cool Hi All,

    Borrowing from others you basically need a Loop!

    10,000 ft overview ... Master Job -> Trans (get file details) -> 2nd Job (execute for each input row) -> Do work!

    Get the file info within a trans then copy to the result set, and use the “execute for every input row” feature of a subsequent job entry. So this implies you have a Master job that calls a Trans (gets file details) then use the "Copy rows to result" step which puts the details you just got in the Trans into the stream. In the Master Job you have another Job after the Trans. You right click/edit that 2nd job entry and make sure you set "execute for every input row".

    From here you can have your 2nd job process that file ... you'll need to access the "stuff" you passed in by using a "Get rows from result" step within a Trans ... or have set Variables that you can then access. Many ways to achieve.

    SLAWO is your friend, check out ...

    http://type-exit.org/adventures-with...-for-each-row/

    http://type-exit.org/adventures-with...n-kettle-jobs/

    Or ... http://vrubleuski.blogspot.com/2010/...in-kettle.html

    Good Luck!

    Kent

  5. #5
    Join Date
    Mar 2011
    Posts
    2

    Default

    Hey guys,

    thank you very much for the help so far!!

    I must admit that all of this is completely new, not to mention a bit difficult to me.
    I will try this out at the weekend, and will give you feedback.

    Best regards
    Stephan


  6. #6
    Join Date
    Apr 2009
    Posts
    12

    Default

    Good stuff - thanks for the direction. The get row from result is the key. Thanks again.

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.