You can use the following awk script to transform the file:
transform.awk:
{
# On the first record this loop runs twice. once
# for the headers once for the first line of data.
# In all subsequent lines is prints only the data
# because h==1.
for(;h<=1;h++){
for(i=1+h;i<=NF;i+=2){
printf "%s ", $i
}
printf "\n"
}
h=1
}
Then execute it like this:
awk -f transform.awk RS='' file
Output:
A B A D E
25 26 14 39 42
74 36 81 96 17
23 14 74 87 17
To get proper aligned columns you can pipe to column -t:
awk -f transform.awk RS='' file | column -t
Output:
A B A D E
25 26 14 39 42
74 36 81 96 17
23 14 74 87 17
The key here is the usage of the variable RS (record separator). Using an empty string for RS separates records by blank lines. It is the same as setting it to \n\n+ (one or more blank lines). The first record for examples will look like this:
A 25
B 26
A 14
D 39
E 42
awk by default splits by [[:space:]]+ which includes newlines. This gives us the following fields for record one.
A 25 B 26 A 14 D 39 E 42
The algorithm shown above transforms this fields to the desired output.