Custom transformer for FME® that transposes (pivots) attributes the easy way
Custom transformer for FME® that transposes attributes so that the value of a selected Column Attribute is turned into a new attribute. In other words, this a simple version of the AttributePivoter, that flips the “rows” and “columns” of a feature attribute table.
The table below shows the original input features and their attributes.
When we set “Attribute2” as the Column Attribute and the Row Attributes to “Attribute4”, “Attribute3” and “Attribute1” (in that order), we would end up with the 3 features, as shown in the second table.
The third table above shows what happens, when we set “Attribute3” as the Column Attribute and the Row Attributes to “Attribute1”, “Attribute2”, “Attribute4” and “Attribute5” (in that order). Notice that we have 4 features now and that the value “test” existed twice, which resulted in a “test” attribute and a “test(1)” attribute. The Column Attribute also contains 2 empty values, that have been turned into “Untitled” and “Untitled(1)” respectively. This is intended behaviour: attributes cannot be overwritten or not written at all because their name is null, empty or missing.
Specify the attribute for which all feature values should be turned into new attributes (i.e. columns). The order in which features arrive, determines the order in which new attributes/columns are created, but since these attributes are not sequenced, this can’t be guaranteed.
Select at least 1 attribute whose values will be used in a “row feature”, effectively forming the attribute values of the Columns Attribute set above. This means that the order in which you specify the Row Attribute(s), determines the feature output order.