Hi All,
I'm trying to use PythonCaller for a few more complex date calculations that I couldn't find how to easily do with other FME transforms. One of the things I need to do is some standard if/else testing to set a variable based on two other feature attribute values for further processing down the chain, however the results are not returning correctly.
I've split out what i'm trying to do into a simple PythonCaller:
import fme
import fmeobjects
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
def processFeature(feature):
#Define vars
completionDate = feature.getAttribute('PREREQ_COMPLETE_DATE')
notRequiredDate = feature.getAttribute('PREREQ_NOTREQUIRED_DATE')
useDate = None
#Test if completionDate is null and fill with notRequiredDate if so
if completionDate is None:
useDate = notRequiredDate
else:
useDate = completionDate
#Set new attributes to expose in FME
feature.setAttribute("useDate", useDate)
pass
useDate will fill with the completionDate when available, however, the features that have notRequiredDate only do not fill useDate as intended.
I'm by no means a python expert, but any help would be appreciated.