Skip to main content
Question

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

  • December 10, 2019
  • 7 replies
  • 319 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)

 

 

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

arnold_bijlsma
Enthusiast
Forum|alt.badge.img+15
  • Enthusiast
  • 126 replies
  • December 10, 2019

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
  • 8394 replies
  • 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
  • 11 replies
  • December 11, 2019

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
  • 11 replies
  • 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
  • 8394 replies
  • 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
  • 11 replies
  • December 11, 2019

that works.

 

thank you very much.

arnold_bijlsma
Enthusiast
Forum|alt.badge.img+15
  • Enthusiast
  • 126 replies
  • December 11, 2019

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.