Skip to main content
Question

FME 2020 Python feature.removeAttribute(attr)

  • June 30, 2020
  • 4 replies
  • 78 views

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)

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.

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

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!