Skip to main content

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

Can you post the python code as code


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?


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


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!


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 


Reply