Skip to main content

Hi

 

Looking at the FME online help for lists, I want to create this type of list in PythonCaller and use it in Workbench as a list:

 
 somelist{0}.length = 7.3 somelist{0}.kind = ’paved’ somelist{1}.length = 8.4 somelist{1}.kind = ’smooth’ somelist{1}.lanes = 2 somelist{2}.length = 1.1 somelist{2}.kind = ’rough’
 

I've created a simple list (element with an index) but struggling using fmeobjects and other libraries in the PythonCaller to create and set this complex list.

 

 

Anyhelp from the Python Jedi out there?  

Thanks

Hi,

 

 

This example help you?

 

-----

 

def processFeature(feature):

 

    # Test data

 

    length, lanes, kind = s7.3, 8,4, 1.1], ,'', 2, ''], 9'paves', 'smooth', 'rough']

 

    

 

    # Create a structured list attribute.

 

    for i, (lgt, lns, knd) in enumerate(zip(length, lanes, kind)):

 

        feature.setAttribute('somelist{%d}.length' % i, lgt)

 

        feature.setAttribute('somelist{%d}.lanes' % i, lns)

 

        feature.setAttribute('somelist{%d}.kind' % i, knd)

 

-----

 

Padawan Takashi
Think that gives me something to work with. Many Thanks Takashi!

Reply