Skip to main content
Question

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

  • December 10, 2019
  • 7 replies
  • 246 views

Forum|alt.badge.img

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

arnold_bijlsma
Enthusiast
Forum|alt.badge.img+14

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.


david_r
Celebrity
  • December 11, 2019

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.

 


Forum|alt.badge.img
  • Author
  • December 11, 2019
arnold_bijlsma wrote:

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


Forum|alt.badge.img
  • Author
  • December 11, 2019

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.

 

 

 


david_r
Celebrity
  • December 11, 2019

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

_list{}.Typ

 


Forum|alt.badge.img
  • Author
  • December 11, 2019

that works.

 

thank you very much.

arnold_bijlsma
Enthusiast
Forum|alt.badge.img+14
luhu wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings