Question

FME 2020 Python feature.removeAttribute(attr)


Badge +1

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

Badge +1

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".

Badge +1

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

Badge +1

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

Badge +1

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!

Reply