Skip to main content
Question

FME 2020 Python feature.removeAttribute(attr)


mferwerda1111
Participant
Forum|alt.badge.img+2

I have a pythoncaller, that runs the below python, this works OK in FME 2018, but fails in 2020.

ERROR |Python Exception <SyntaxError>: invalid syntax (<string>, line 11)

FATAL |Factory proxy not initialized

I have the python interpreter set to 3.6+

So the script works in 2020 if I tag out the last line, so has something changed with the feature.removeAttribute function ?

 

import fmeobjects

def removeNulls(feature):

attrsin = feature.getAttribute('SRC_ATTRS')

attrs = attrsin.split(',')

for attr in attrs:

val = feature.getAttribute(attr)

if val == 'VCP' :

feature.setAttribute('attname',attr)

if val <> 'VCP' :

feature.removeAttribute(attr)

4 replies

Forum|alt.badge.img+1
  • June 30, 2020

Isn't the syntax error the if-clause val <> 'VCP'? It should be val != 'VCP' to be correct in Python 3. Seemingly, it works in Python 2 with "a" <> "b".


mferwerda1111
Participant
Forum|alt.badge.img+2
  • Author
  • Participant
  • June 30, 2020

Yep, that is it, you can tell I am not up on python, really appreciate the


mferwerda1111
Participant
Forum|alt.badge.img+2
  • Author
  • Participant
  • June 30, 2020

Yep, that was it, you can tell I am not up on python, really appreciate the help.


Forum|alt.badge.img+1
  • June 30, 2020
mferwerda1111 wrote:

Yep, that was it, you can tell I am not up on python, really appreciate the help.

No problems! I didn't know you could write <> not equals-statements in Python 2, so we've both learned!


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