I have a tab delimited file, for which I need to concatenate selective columns into a key-value pair. Let’s say my first three columns stay the same, but after that, I can expect any number of columns. All the columns after the third should concatenate into a key-value pair.
Here is my data set:
col1 col2 col3 col4 col5
1 2 3 4 5
Result
col1 col2 col3 col4|col5
1 2 3 col4 => 4 | col5 => 5
If you have the following input file:
Then pulling off the header, splitting and destructuring each line can be done with something like:
Running that gives:
Is this what you’re after?