Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Run Python code from Kettle PDI

  1. #1
    Join Date
    Aug 2013
    Posts
    6

    Default Run Python code from Kettle PDI

    Looking for Kettle sample/example that will do the following...

    Step 1 - Kettle passes a large file (cvs/txt) to a python module
    Step 2 - Python Module reads the (whole/complete) large file, adds several more columns, writes out revised file
    Step 3 - Kettle reads revised file (line by line) and outputs to Oracle db (each line is one row).

    Any help appreciated.

  2. #2
    Join Date
    Aug 2013
    Posts
    6

    Default

    Responding to my own post, now that i have answer I can share. Below, only proves/test that python can be called from PDI Kettle (.kjb)

    Use Shell Script in Kettle Job - point to the python .py file (make sure .py file is executable $ chmod +x test.py)

    I found this post useful

    https://morannachum.wordpress.com/2015/02/23/running-scripts-in-pentaho-kettle/

    my test.py script looks like this

    #!/usr/bin/pythonimport time
    print (time.strftime("%H:%M:%S"))
    print (time.strftime("%d/%m/%Y"))

    PDI Kettle Job output below

    2015/11/15 11:07:41 - Spoon - Starting job...
    2015/11/15 11:07:41 - pythontest - Start of job execution
    2015/11/15 11:07:41 - pythontest - Starting entry [test.py]
    2015/11/15 11:07:41 - test.py - Running on platform : Mac OS X
    2015/11/15 11:07:41 - test.py - Executing command : /Users/username/test.py
    2015/11/15 11:07:41 - test.py - (stdout) 11:07:41
    2015/11/15 11:07:41 - test.py - (stdout) 15/11/2015
    2015/11/15 11:07:41 - pythontest - Starting entry [Success]
    2015/11/15 11:07:41 - pythontest - Finished job entry [Success] (result=[true])
    2015/11/15 11:07:41 - pythontest - Finished job entry [test.py] (result=[true])
    2015/11/15 11:07:41 - pythontest - Job execution finished
    2015/11/15 11:07:41 - Spoon - Job has ended.

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.