Question

How to create a list (from feature attributes) in PythonCaller similair to the ListBuilder

  • 10 December 2019
  • 7 replies
  • 49 views

Badge

Hi,

i would like to define a list in the "PythonCaller" Transformer using incomming feature attributes. In addition, the list should be group by an attribute and sould output the same as the "ListBuilder" below.

 

ListBuilder with incomming attribuit group by "Vorschrift" (=attribute)

 

Definition in PythonCaller. how should the python code looks like for define a list using incomming attributes?

 

desired output (=output of the ListBuilder above)

 

 

 

 


7 replies

Badge +3

Not an answer, which is why I'm putting it as a comment: in most instances, Python should not be your first port of call for any solution. Always try to use the power of the transformers. There are many list transformers, and probably one is close enough to what you're trying to achieve.

Userlevel 4

Is there a particular reason for wanting to do this with Python? It is definitely possible, but it's not going to be a one-line solution.

If you need to build a list with a group-by and a certain number of attributes you can use the Aggregator.

 

Badge

Not an answer, which is why I'm putting it as a comment: in most instances, Python should not be your first port of call for any solution. Always try to use the power of the transformers. There are many list transformers, and probably one is close enough to what you're trying to achieve.

you're right. this is was i did (using transformers) and it works in the workspace.

 

But,

the combination of 4 list transformers does not work in a custom transformer.

this is the reason why i'm using the pythoncaller

Badge

yes there is. the one-line solution does not work if i create a custom transformer when using a ListSorter after a ListBuilder...

in the normal workspace it works.

 

workspace (works!)

 

custom transformer (doesn't work)

Problem (in custom transformer):

after creating a list named "_list" in the ListBuilder it isn't possible to define the "List Attribute:" in the ListSorter.

 

So I want to work around this problem with the PythenCaller.

 

in my opinion there is nothing to do with Interlis.

 

 

 

Userlevel 4

In your custom transformer, before the ListSorter, you can try and insert an AttributeExposer configured to expose

_list{}.Typ

 

Badge

that works.

 

thank you very much.
Badge +3

you're right. this is was i did (using transformers) and it works in the workspace.

 

But,

the combination of 4 list transformers does not work in a custom transformer.

this is the reason why i'm using the pythoncaller

Good to see you got it resolved with just a simple fix and without Python.

Reply