Skip to main content
Solved

How to rename List Attribute to a List Attribute Component


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist

So, what would be the easiest way to do this. Lets say we have generated 2 separate, but parallel Lists like this (say from ListExpressionPopulator):

  • Colours{}
  • Precincts{}

And it is desired to combine these into a single list with the original list names as instead the component names like this:

  • Report{}Colours
  • Report{}Precincts

As far as I can tell, this can't be done with either ListRenamer or AttributeRenamer, and the closest got to is using BulkAttributeRenamer.

Best answer by takashi

Hi @bwn, as far as I know, except scripting (Python, Tcl, XQuery etc.), the only way is to use the BulkAttributeRenamer with Regular Expression Replace mode, as in:

Attributes to Rename:
    Rename: All Attributes
Parameters:
    Action: Regular Expression Replace
    Mode: Rename
    Text To Find: (Colours|Precincts){(\d+)}
    String: Report{\2}.\1

However, the BulkAttributeRenamer won't expose the new list names and also won't hide the old list names. You will have to expose the new names and hide the old names in the subsequent process if necessary.

View original
Did this help you find an answer to your question?

7 replies

takashi
Influencer
  • Best Answer
  • February 5, 2020

Hi @bwn, as far as I know, except scripting (Python, Tcl, XQuery etc.), the only way is to use the BulkAttributeRenamer with Regular Expression Replace mode, as in:

Attributes to Rename:
    Rename: All Attributes
Parameters:
    Action: Regular Expression Replace
    Mode: Rename
    Text To Find: (Colours|Precincts){(\d+)}
    String: Report{\2}.\1

However, the BulkAttributeRenamer won't expose the new list names and also won't hide the old list names. You will have to expose the new names and hide the old names in the subsequent process if necessary.


takashi
Influencer
  • February 5, 2020
takashi wrote:

Hi @bwn, as far as I know, except scripting (Python, Tcl, XQuery etc.), the only way is to use the BulkAttributeRenamer with Regular Expression Replace mode, as in:

Attributes to Rename:
    Rename: All Attributes
Parameters:
    Action: Regular Expression Replace
    Mode: Rename
    Text To Find: (Colours|Precincts){(\d+)}
    String: Report{\2}.\1

However, the BulkAttributeRenamer won't expose the new list names and also won't hide the old list names. You will have to expose the new names and hide the old names in the subsequent process if necessary.

Alternatively, the ListZipper transformer from FME Hub might help you.


bwn
Evangelist
Forum|alt.badge.img+26
  • Author
  • Evangelist
  • February 5, 2020
takashi wrote:

Alternatively, the ListZipper transformer from FME Hub might help you.

Thanks @takashi, that's almost identical to the solution using as well. I was just wondering if I had missed any simpler solutions as it gets a little inelegant having to brute force exposing the renamed List Attributes with AttributeExposer.

Almost all the List Creation or Alteration Transformers don't seem to be able to output Lists with Component Labels from experimenting with most of them?


bwn
Evangelist
Forum|alt.badge.img+26
  • Author
  • Evangelist
  • February 5, 2020
takashi wrote:

Alternatively, the ListZipper transformer from FME Hub might help you.

...Oh and I like the functionality of ListZipper too @takashi. Another nice contribution from yourself to the Custom Transfomer Hub!


takashi
Influencer
  • February 5, 2020
takashi wrote:

Hi @bwn, as far as I know, except scripting (Python, Tcl, XQuery etc.), the only way is to use the BulkAttributeRenamer with Regular Expression Replace mode, as in:

Attributes to Rename:
    Rename: All Attributes
Parameters:
    Action: Regular Expression Replace
    Mode: Rename
    Text To Find: (Colours|Precincts){(\d+)}
    String: Report{\2}.\1

However, the BulkAttributeRenamer won't expose the new list names and also won't hide the old list names. You will have to expose the new names and hide the old names in the subsequent process if necessary.

@bwn, please add a comment to and vote up these ideas ;-)

https://knowledge.safe.com/content/idea/19590/easy-way-to-create-structured-list-from-multiple-c.html 

https://knowledge.safe.com/content/idea/59213/listrenamer-allow-demotions.html


bwn
Evangelist
Forum|alt.badge.img+26
  • Author
  • Evangelist
  • February 5, 2020
takashi wrote:

Upvoted! Yes similarly how trouble trying to deal with the output of AttributeSplitter used on multiple Attributes to generate parallel lists. ListRenamer etc. was among the first Transformers that I investigated to see if they could turn simple lists into Structured lists with components and your previous posting a couple of years ago using BulkAttributeRenamer as a workaround the best could find.


takashi
Influencer
  • February 5, 2020
takashi wrote:

Hi @bwn, as far as I know, except scripting (Python, Tcl, XQuery etc.), the only way is to use the BulkAttributeRenamer with Regular Expression Replace mode, as in:

Attributes to Rename:
    Rename: All Attributes
Parameters:
    Action: Regular Expression Replace
    Mode: Rename
    Text To Find: (Colours|Precincts){(\d+)}
    String: Report{\2}.\1

However, the BulkAttributeRenamer won't expose the new list names and also won't hide the old list names. You will have to expose the new names and hide the old names in the subsequent process if necessary.

Here is another solution: MultiAttributeSplitter

https://hub.safe.com/publishers/pacific-spatial-solutions/transformers/multiattributesplitter 


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