Page 1 of 1

Add column names as rows

Posted: Thu Sep 11, 2014 11:19 pm
by sreesuku2
I have file in the below format

Code: Select all

ID	Sev 1 	Sev 2 	Sev 3
ABC	0.45	1	1
PQR	0.45	1	2
XYZ	0.45	1	1
I want to change this to the new format as below

Code: Select all

ID	Severity	Values
ABC	Sev1	0.45
ABC	Sev2	1
ABC	Sev3	1
PQR	Sev1	0.45
PQR	Sev2	1
PQR	Sev3	2
XYZ	Sev1	0.45
XYZ	Sev2	1
XYZ	Sev3	1
To bring the column names as rows and add the corresponding values.

Regards
Sree

Posted: Thu Sep 11, 2014 11:30 pm
by ray.wurlod
Upstream of the Pivot stage generate a delimited list of column names, and pivot on that also.

Posted: Fri Oct 24, 2014 3:58 pm
by roy
Hi,
You can "simply" use the Hashed file pivot option.
Step 1 transform your records so:
ID column gets te ID value
Data column gets the string "Sev1|": <sev2 column data> : @VM "Sev2|": ... and so on
then when you read the Hashed file normalize on the data field and write to a seq fle with | as filed delimiter youll ge he file with wha you want
(After you set it in the column definition as a MV type column)

actually after achieving the desired format you can use the pivot stage to the same effect (if ou have a finite and constant number of fields.

IHTH ( I Hope This Helps),