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.

  • 25 August 2021
  • 5 replies
  • 0 views

Badge

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

Badge +4

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!

 

Badge +2

@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

 

 

Badge

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
Badge

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!

Badge

@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.

Reply