Question

Python caller gives no output

  • 22 April 2024
  • 6 replies
  • 70 views

Badge

When i use the python caller i get a translation successful, but it gives no output.

I'm not very good at python, so do any of you have an idea what i did wrong?

 


6 replies

Userlevel 3
Badge +19

One tip might be to capture some of the Python processing into your FME transaction log https://support.safe.com/s/article/logging-with-python-scripts

 

In a PythonCaller (or PythonCreator) transformer, messages are added to the logfile with the FMELogFile object, which is part of the fmeobjects. You need to create a logger object: logger = fmeobjects.FMELogFile() and then you will need to send messages to the logger: logger.logMessageString("Hello I am Logging Now")

Userlevel 4
Badge +18

On what row did you type:

self.pyoutput(feature)

?

Userlevel 5
Badge +29

  

As @jkr_wrk mentioned, you’re missing

self.pyoutput(feature)

The purpose of this line is to output the resulting features. At a guess, you’d want this to be on line 25, indented to the same level as line 18.


Having it here will output every feature you input into the pythoncaller

Badge

Hello,

If your python script completes without errors but lacks output, check for print statements to ensure results are displayed. Verify input handaling and run the script interactively for step by step debugging. Look for silent errors in the console and test with sample data to confirm expected behavior.

Userlevel 5
Badge +36

I'm no python expert, but these lines look very strange:

y = 'true' if not feature.getattribute('Score 6 t/m 18') else 'false' 

if "bebouwing" in x and y == "true": 

I'm pretty certain this will not do what you want it to do.

Userlevel 4
Badge +18

I did not look into all the PythonCaller code before.

FME is in principal a NoCode application to do all the things you want to do. It looks like you don't have much experience in coding in Python or using Python in FME.

The function you are writing is very easy to do using 1 or 2 transformers, so it looks like you should keep away from the PythonCaller.

Except when your only goal is to learn to use the PythonCaller in general because you are certain that there are things you want to do that FME can't do with basic transformers.

Reply