Transpose columns in table Let's say you've got a table of data:

meter_id date   0000 0600 1200 1800
0        030915 10   20   30   40
1        030915 15   7    49   2


where the last four columns are meter readings at different times. You want to output

meter_id date   time reading
0        030915 0000 10
0        030915 0600 20


etc.

Your input and output will not have headers, unlike in this example. The set of columns you'll transpose will be provided as numeric arguments to your program, from 1 onwards. Input is stdin and output is stdout.

So here's an example of it actually being used.

$ ./tpose 3 4 5 6


Stdin:

0        030915 10   20   30   40
1        030915 15   7    49   2


Stdout:

0       030915  3       10
0       030915  4       20
0       030915  5       30
0       030915  6       40
1       030915  3       15
1       030915  4       7
1       030915  5       49
1       030915  6       2


The third column contains values from 3 to 6. This is because the reading is from columns 3 to 6 from the input table.

Happy golfing.
kdb k, 101 bytes
1@&quot;\n&quot;/:{&quot;\n&quot;/:{&quot; &quot;/:(r@&amp;{~#&amp;x=a}'!#r),(,$1+a@x),,c@x}'!#c::(r::&quot; &quot;\:x)@a::-1+.:'.z.x}'-1_&quot;\n&quot;\:0::0;

Me: (reads the word &quot;transpose&quot; in the title) K will be perfect for this! It'll kick everything else's hind!
20 minutes and 101 bytes later
Me: Idiot.