Skip to main content

Hi,

I’m trying
to transpose the following table from SQL Server:

KriterieTestparameterVerdi 1Verdi 2Verdi 31UNIKEnToTre2STADNasjonal5PROD123

Into this
table (first row as column name):

TestparameterUNIKSTADPRODVerdi 1En1Verdi 2To2Verdi 3TreNasjonal3Kriterie125

Using this article,
I’m able to transpose the table into (column name like A-G): https://knowledge.safe.com/articles/31701/transpose-a-table-using-fme.html

But for
further use the column name must be the first row, not A-G.

How can I set
first row as column name?

I’ve tried
using the AttributeCreator with values from a second list, and exposing the
dynamic attributes afterword’s, but I can’t get it to work..

Attribute name from list example:

New
Attribute = @Value(_testpara_attri{0}._testpara_value)

Attribute
value = attrs{0}._attr_value

Where _testpara_attri{}
is the list with column names, and attrs{} is the list from the transpose routine.

Workspace:

Hi @odinaltin, are you writing out to an existing table?
Hi @odinaltin, are you writing out to an existing table?
Hi! Tried both with no luck.

 

 


Hi @odinaltin,

Check out the attached workflow. I've been working on a 'TableTransposer' custom transformer which is included in the workflow. It's not ideal yet but it should give you what you want. You may still need some extra tweaks to get exactly what you're after.

 

 

The problem with doing a Transpose in FME is that the original schema gets destroyed and FME doesn't know how to build the outgoing table unless it gets some further info. There is another handy tool called the SchemaSetter which creates a 'SchemaFeautre' for each feature. The writer can be set to build the schema from these schema features.

 

 

You are limited in the amount of control you have over column positions so it may not be what you're after.

 

csv22csv2.fmwt

Hi @odinaltin,

Not sure if it is helpful in your situation, but I just uploaded the AttributeTransposer to FME Hub.

Sander


Hi @odinaltin,

Not sure if it is helpful in your situation, but I just uploaded the AttributeTransposer to FME Hub.

Sander

Love it @sander! We really have needed something like this. This, coupled with the SchemaSetter can be very powerful

 


Love it @sander! We really have needed something like this. This, coupled with the SchemaSetter can be very powerful

 

Thanks Matt!

 

Meant to submit this transformer earlier, as I already started working on this thing a week ago or something, but didn't have much time...

 


Reply