Skip to main content
Question

How Do I Use a Python Code in FME


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)

 

4 replies

david_r
Evangelist
  • 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+48

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


  • Author
  • August 21, 2019
david_r wrote:

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
Evangelist
  • August 21, 2019
datanomad wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings