Skip to main content
Question

I know how to split a specific attribute with AttributeSplitter. However, what I want to do is to split a few dozens of attributes in one go. I guess there must be an easier way than using a separate splitter for each attribute.


Forum|alt.badge.img

What I want to achieve is:

colour is split into list attribute colour{}

nationality is split into list attribute nationality{}

status is split into list attribute status{}

size is split into list attribute size{}

shape is split into list attribute shape{}

etc. in one go.

 

Thanks for you help

5 replies

davtorgh
Contributor
Forum|alt.badge.img+10
  • Contributor
  • August 25, 2021

Hi @friedhelm​ ,

 

maybe I have found a solution. The method is a bit different but I think it should work.

 

The basic idea is to use a unique identifier for each feature, create attribute <name, value> pairs (eg. <color, somecolor>, <status, somestatus>, etc.) and split the values with a separator character. The unique identifier can help to keep track of the original feature that the new features came from.

 

In the attached example:

  • the unique identifier is '_creation_instance';
  • the AttributeCreator creates some string in ISO date time format ("T" is the character used to separate the date part from the time part and is choosen as splitter in the next steps);
  • the AttributeSplitter splits by "T".

 

Hope that helps!

 


Forum|alt.badge.img+2
  • August 26, 2021

@davtorgh​ BulkAttributeRenamer can be used to rename lists. Not an obvious choice, but you can use it to demote and promote lists when the ListRenamer sometimes isn't flexible enough. For example:

    array{0}.name1

    array{1}.name2

to

name1

name2

using a regex:

array\\{\\d+\\}\\.

 

In your case, you can rename all the lists to a complex list, then a single AttributeExploder should do the trick:

status{}

nationality{}

to

mylist{}.status

mylist{}.nationality

AttributeExploder on mylist{}

In BulkAttributeRenamer, the regex you can use is:

(\\w+){(\\d)}

and replacement string:

mylist{\\2}.\\1

In the regex, the () creates capture groups and then in the replacement string, the \\1 & \\2 are those groups. So (\\w+) captures the name of the attribute and (\\d) the index.

dialogI've attached an example workspace

All this assumes that you have the same number of list elements in all your lists

 

 


Forum|alt.badge.img
  • Author
  • August 26, 2021
davtorgh wrote:

Hi @friedhelm​ ,

 

maybe I have found a solution. The method is a bit different but I think it should work.

 

The basic idea is to use a unique identifier for each feature, create attribute <name, value> pairs (eg. <color, somecolor>, <status, somestatus>, etc.) and split the values with a separator character. The unique identifier can help to keep track of the original feature that the new features came from.

 

In the attached example:

  • the unique identifier is '_creation_instance';
  • the AttributeCreator creates some string in ISO date time format ("T" is the character used to separate the date part from the time part and is choosen as splitter in the next steps);
  • the AttributeSplitter splits by "T".

 

Hope that helps!

 

Hi thanks - I will check if this works for me. Best regards Kind regards, Friedhelm Moggert-Kägeler Solutions Director Maritime Spatial Data SevenCs GmbH Atlantic Haus Zirkusweg 1, 20359 Hamburg, Germany Phone +49 40 851 72 40 Fax +49 40 851 72 479 www.sevencs.com

Forum|alt.badge.img
  • Author
  • August 30, 2021
davtorgh wrote:

Hi @friedhelm​ ,

 

maybe I have found a solution. The method is a bit different but I think it should work.

 

The basic idea is to use a unique identifier for each feature, create attribute <name, value> pairs (eg. <color, somecolor>, <status, somestatus>, etc.) and split the values with a separator character. The unique identifier can help to keep track of the original feature that the new features came from.

 

In the attached example:

  • the unique identifier is '_creation_instance';
  • the AttributeCreator creates some string in ISO date time format ("T" is the character used to separate the date part from the time part and is choosen as splitter in the next steps);
  • the AttributeSplitter splits by "T".

 

Hope that helps!

 

Great - together with the solution markatsafe proposed this worked for me. Thank you!


Forum|alt.badge.img
  • Author
  • August 30, 2021
markatsafe wrote:

@davtorgh​ BulkAttributeRenamer can be used to rename lists. Not an obvious choice, but you can use it to demote and promote lists when the ListRenamer sometimes isn't flexible enough. For example:

    array{0}.name1

    array{1}.name2

to

name1

name2

using a regex:

array\\{\\d+\\}\\.

 

In your case, you can rename all the lists to a complex list, then a single AttributeExploder should do the trick:

status{}

nationality{}

to

mylist{}.status

mylist{}.nationality

AttributeExploder on mylist{}

In BulkAttributeRenamer, the regex you can use is:

(\\w+){(\\d)}

and replacement string:

mylist{\\2}.\\1

In the regex, the () creates capture groups and then in the replacement string, the \\1 & \\2 are those groups. So (\\w+) captures the name of the attribute and (\\d) the index.

dialogI've attached an example workspace

All this assumes that you have the same number of list elements in all your lists

 

 

Thanks - BulkAttributeRenamer was a good idea.


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