I have a file import that has x-number of columns. I want to create an automated enumerator that updates it's values based on the column-labels of the import files.
But in order to do that, I need to transpose the column lables of the import file to values of a single column.
So - f.ex. the file looks like this:
Column1 | Column2 | Column3 | Column4 | Column5 |
---|---|---|---|---|
Data 1 | Data 2 | Data 3 | Data 4 | Data 5 |
Data 1 | Data 2 | Data 3 | Data 4 | Data 5 |
Data 1 | Data 2 | Data 3 | Data 4 | Data 5 |
I want to get this kind of result:
Label of Columns |
---|
Column 1 |
Column 3 |
Column 3 |
Column 4 |
Column 5 |
So I could then add the values of "Label of Columns" as Enumerator values to my enumerator.
How to do this (either via normal activities - which I doubt will bend to this - or with JS-code).
The main criteria are:
- Having a single column with the names of the columns of the imported file
- The number of columns can vary in the import file.
- Mikael -
Solved! Go to Solution.
Hi Mikael,
In advance tab of Data loading activity
Add below code to get column header information. Once you get comma separated list of columns header just split this and save it in Enumeration. This is also dynamic in nature so number of columns can vary this will give you proper result.
1. var colHeader = activity.source.dataSourceConfig.sampleLines.line[0]
2. var arrayCol = colHeader .split(',') ;
3. Use for loop to have values and save this in ENUM.
I hope this helps.
Thanks,
Kapil
Hi Mikael,
In advance tab of Data loading activity
Add below code to get column header information. Once you get comma separated list of columns header just split this and save it in Enumeration. This is also dynamic in nature so number of columns can vary this will give you proper result.
1. var colHeader = activity.source.dataSourceConfig.sampleLines.line[0]
2. var arrayCol = colHeader .split(',') ;
3. Use for loop to have values and save this in ENUM.
I hope this helps.
Thanks,
Kapil
Here's my final code just as an full example, I'm not a "proper" coder so it might not be the prettiest and there are some "cleaning" possible and the columns had 2 values I didn't want to put in the enumerator, so I rather crudely omitted them with two if/else clauses... but anyway:
Views
Replies
Total Likes