Hello,
I'm using linejoiner to reduce the number of segments in a street map. Each segment MAY have a from_address and to_address, so after the line joining I have a list of the froms and tos for the segments. I want to process that list in Python.
I'm working through it and learning to process the lists with the PythonCaller function below:
import fme
import fmeobjects
def processFeature(feature):
nn = feature.getAttribute('Full_Name')
if nn == 'John A MacDonald Rd':
print nn,
addr = feature.getAttribute("C:\GIS\SK\Saskatoon\Roads\Roads.sl3{}.From_Address")
try:
if len(addr) > 0:
print len(addr), [x for x in addr if x is not None]
except:
print 'nothing'
I've also exposed the attributes for the list, so I can inspect them manually in the inspector.
What I've found is that if I have a list that starts with a NULL the len function throws an exception, which means that if the first item in a list is NULL the getAttribute function returns a NULL rather than a list with a NoneObject at the beginning of the list.
Can anyone suggest a workaround?