Skip to main content
Solved

I have a PythonCaller that worked in FME 2017, when I migrated to FME 2019 it is erroring


This is the error I receive from the PythonCaller:

Python Exception <ValueError>: 'L' is not in list

Traceback (most recent call last):

File "<string>", line 22, in input

ValueError: 'L' is not in list

Error encountered while calling method `input'

PythonCaller_3 (PythonFactory): PythonFactory failed to process feature

 

Here is the python in the PythonCaller: it's reading two attributes from the ListBuilder. This runs on the same data without error in FME 2017

 

# Template Class Interface:

# When using this class, make sure its name is set as the value of

# the 'Class or Function to Process Features' transformer parameter

class FeatureProcessor(object):

def __init__(self):

pass

def input(self,feature):

self.listC = feature.getAttribute('_list{}.c')

self.listL = feature.getAttribute('_list{}.l')

self.list = zip(self.listC,self.listL)

#

if self.list != None:

self.check = []

for i,e in enumerate(self.list):

if e[1] == 'M':

self.check.append(e[0])

if not self.check:

self.add = []

for i,e in enumerate(self.list):

self.add.append(e[1])

val = self.add.index('L') + 1

for i,e in enumerate(self.list):

x = i + 1

if x == val:

feature.setAttribute('_list{%d}.l' %i,'M')

self.pyoutput(feature)

def close(self):

pass

Best answer by ebygomm

My guess would be that you've changed from Python 2.7 to 3.x and your script needs to be updated to run

e.g. zipping a list has definitely changed between the two so this line

self.list = zip(self.listC,self.listL)

would become this

self.list = list(zip(self.listC,self.listL))

There may be other changes required also, it's hard to tell without the code formatting and the source data

View original
Did this help you find an answer to your question?

5 replies

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • May 4, 2020

Can you post the python code as code


david_r
Celebrity
  • May 4, 2020

Did you perhaps change from Python 2.7 to 3.x? The two versions aren't fully compatible.

Also, are you 100% sure that the input data is identical between the two FME versions?


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • Best Answer
  • May 4, 2020

My guess would be that you've changed from Python 2.7 to 3.x and your script needs to be updated to run

e.g. zipping a list has definitely changed between the two so this line

self.list = zip(self.listC,self.listL)

would become this

self.list = list(zip(self.listC,self.listL))

There may be other changes required also, it's hard to tell without the code formatting and the source data


  • Author
  • May 4, 2020
david_r wrote:

Did you perhaps change from Python 2.7 to 3.x? The two versions aren't fully compatible.

Also, are you 100% sure that the input data is identical between the two FME versions?

The above post was correct -- It was the zipping. thank you so much for your help!


  • Author
  • May 4, 2020
ebygomm wrote:

My guess would be that you've changed from Python 2.7 to 3.x and your script needs to be updated to run

e.g. zipping a list has definitely changed between the two so this line

self.list = zip(self.listC,self.listL)

would become this

self.list = list(zip(self.listC,self.listL))

There may be other changes required also, it's hard to tell without the code formatting and the source data

Thank you!  That was the issue!!! I 


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