Skip to main content
Hi,

 

 

I would like to create 72 features with predefined ID and NAME attributes for instance:

 

 

ID    NAME

 

689  Kativic

 

711  Monts et marées

 

712  Charlevoix

 

...     ...

 

 

So far I used the creator (1 instance) followed by AttributeCreator where I added all IDs separated by a coma into 1 attribute. Then I used the AttributeSplitter to create a list on the IDs and finally the ListExploder.

 

 

 

 

The result is ok, I have one feature with the ID, but I cant find a way to have the NAME attribute also attached to those features. Instinctively, I would use a JSON key:value list, but I am not sure how and if it is the correct solution.

 

 

Thank you for your help

 

 
Hi,

 

 

There is an interesting usage of the BulkAttributeRenamer.

 

That is, you can use the transformer to change a simple list (e.g. "_list{}") to a component of structured list (e.g. "_list{}.id").

 

Rename: All Attributes

 

Action :Regular Expression Replace

 

Text To Find: }$

 

String: }.id

 

 

Assuming that you have comma separated IDs and Names:

 

First, use an AttributeSplitter to split IDs, then change the resulting list to "_list{}.id" with a BulkAttributeRenamer.

 

Next, create "_list{}.name" with another combination of AttributeSplitter and BulkAttributeRenamer.

 

And then apply the ListExploder to the features. Every output feature will have "id" and "name" as attributes.

 

 

There should be several ways to get the same result.

 

 

Takashi
Hi Takashi,

 

 

In the BulkAttributeRenamer, I have to select an index in the list to add a suffix, it seems I cant select the whole list. "_list{0}.id" and "_list{0}.name" works only for the first feature going out of the list exploder
oh sorry, I just have to do _list{0-72} to select the whole list

The solution from @takashi similarly solved my problem. Genius! I was trying to figure out how to simply merge 4 parallel lists (created from 4 x AttributeSplitters) into 1 list with 4 component attributes.

Eg. Parallel lists SubTypeCode{} and SubTypeDescription{}

into SubTypes{}SubTypeCode and SubTypes{}SubTypeDescription

The solution from @takashi takes advantage of "Lists" just being a set of indexed Attributes, so similarly BulkAttributeRenamer can be used like this:

  • Text to Find: (.+)({\\d+}) - Note the two sets of brackets (). In transformers using Regular Expressions, often you can reuse the bracketed expressions in the replacement text
  • Replacement Text: SubTypes\\2\\1. So if there is a List Attribute SubTypeCode{12} then the replacement string for the attribute names is calculated as "SubTypes" as the prefix followed by the contents of the second bracketed expression and then the first bracketed expression to make SubTypes{12}SubTypeCode

Finally, an AttributeExposer to expose the List Attributes "SubTypes{}" finishes it off!


Reply