Skip to main content
Solved

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

  • May 4, 2020
  • 5 replies
  • 153 views

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

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.

5 replies

ebygomm
Influencer
Forum|alt.badge.img+45
  • 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+45
  • 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

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

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