Skip to main content

Hi,

I would like to transpose attribute where the unique values in attr_names are columns and the rows are grouped correctly. What I mean is that the values has to be attached to correct feature (see attached picture).

The attributes need to be grouped in one row as presented below in the picture with the colors on the side.

 

FME version: 2020.1

The first step will be to get the values into the various attributes. Use an AttributeCreator with NewAttribute set to @Value(_attr_name) and Attribute Value set to _attr_value.

 

Use an AttributeExposer to expose all the attributes to make it easier to continue with.

 

The next step is to group them together, there are a number of ways to do this, one is to add a counter and calculate the modulus of 6 on that.

 

Then use an Aggregator grouping by that modulus to join them into records.

 

Let me know if you want a sample workspace.


There are some detailed examples at: https://community.safe.com/s/article/transpose-a-table-using-fme


The first step will be to get the values into the various attributes. Use an AttributeCreator with NewAttribute set to @Value(_attr_name) and Attribute Value set to _attr_value.

 

Use an AttributeExposer to expose all the attributes to make it easier to continue with.

 

The next step is to group them together, there are a number of ways to do this, one is to add a counter and calculate the modulus of 6 on that.

 

Then use an Aggregator grouping by that modulus to join them into records.

 

Let me know if you want a sample workspace.

Hi,

Thanks for your reply!

I've been trying to use your example above like the linked example philipwhitten posted below before I decided to write a question but I didnt manage to make it work though. The problem is that the input reader in excel format can vary because this script will be used in FME server app and the user can choose what excelfile to use every time they run it. Please see the picture attach in the post where the relevant reader and transformers are marked with a red pencil.


Hi,

Thanks for your reply!

I've been trying to use your example above like the linked example philipwhitten posted below before I decided to write a question but I didnt manage to make it work though. The problem is that the input reader in excel format can vary because this script will be used in FME server app and the user can choose what excelfile to use every time they run it. Please see the picture attach in the post where the relevant reader and transformers are marked with a red pencil.

My ideas were based on a static format for the input so if that is changeable it will be more complicated. I'll have to have a think about it some more. Maybe a DuplicateFilter first to get all the attribute names and then do something with that....


Hi,

Thanks for your reply!

I've been trying to use your example above like the linked example philipwhitten posted below before I decided to write a question but I didnt manage to make it work though. The problem is that the input reader in excel format can vary because this script will be used in FME server app and the user can choose what excelfile to use every time they run it. Please see the picture attach in the post where the relevant reader and transformers are marked with a red pencil.

I use an attributeexploder to extract all the values from the excelfile and then I used tester to filter out format attributes and kept all relevant attributed through the failure output in the tester transformer (see the picture above). So this part is already solved. I just need to transpose them correctly.


Reply