Skip to main content
Question

How Do I Use a Python Code in FME

  • August 13, 2019
  • 4 replies
  • 76 views

I have a python code, here is an example, how will I set it up in a Python Startup Script or even a Pythoncaller. Here is a sample code. I know some might be able to do everything I am trying to do in FME, for the moment I will like to use my available python codes in FME, hence my question.

def my_function(food):

for x in food:

print(x)

fruits = ["apple", "banana", "cherry"]

my_function(fruits)

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

david_r
Celebrity
  • 8394 replies
  • August 13, 2019

Assuming that your "real" code doesn't depart from the sample code in a major way, I can't see why it shouldn't work pretty much as-is.

Have you tried simply copying your code into the startup script? What happened?


redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3701 replies
  • August 13, 2019

There's some tutorials that should help you get underway: https://knowledge.safe.com/articles/706/python-and-fme-basics.html


  • Author
  • 11 replies
  • August 21, 2019

Assuming that your "real" code doesn't depart from the sample code in a major way, I can't see why it shouldn't work pretty much as-is.

Have you tried simply copying your code into the startup script? What happened?

I am able to successfully run it in the startup and shutdwon script, just not in the pythoncaller. My goal is to be able to pass values from the pythoncaller directly to a transformer in FME without having to save the data somewhere locally before proceeding in my workflow. Will like the pythoncaller to hand over to a transformer in same workspace.

Thanks


david_r
Celebrity
  • 8394 replies
  • August 21, 2019

I am able to successfully run it in the startup and shutdwon script, just not in the pythoncaller. My goal is to be able to pass values from the pythoncaller directly to a transformer in FME without having to save the data somewhere locally before proceeding in my workflow. Will like the pythoncaller to hand over to a transformer in same workspace.

Thanks

If you can post a minimal workspace here that demonstrates what you want to accomplish, perhaps we can help you find a solution.