Try this; adapting/extending the header line will include the respective fields in your .csv file:
awk -F: 'BEGIN {HD="Version,Exploitation_Mode,Filter_Type,Aux_Nb_Trace,Seis_Nb_Trace,Total_Nb_Trace,Nb_Of_Dead_Seis_Channels,Nb_Of_Live_Seis_Channels,Dead_Seis_Channels"
print HD
HDCnt=split(HD,HDArr,",")
NXTREC="Observer_Report"
HDCM=","HD","
}
{gsub (/[\t ]*|\*/, "", $1); sub (/^[\t ]*/, "", $2); sub (/[\t ]*$/,"", $2)}
$1 == NXTREC && PR {for (i=1; i<=HDCnt; i++) printf "%s,", RES[HDArr]
printf "%d\n", NR
delete RES
}
$1 == NXTREC {PR=1}
HDCM ~ "," $1 "," {RES[$1]=$2}
END {for (i=1; i<=HDCnt; i++) printf "%s,", RES[HDArr]
printf "\n"
}
' /tmp/342.raw
There's no error checking included nor the conversions like "msec" -> "" etc. that you have in your posted scripts.
---------- Post updated at 18:40 ---------- Previous update was at 15:48 ----------
I had to correct the script for data fileds that contain ":" like the Date entry:
awk -F: 'BEGIN {HD="Version,Exploitation_Mode,Filter_Type,Date,Aux_Nb_Trace,Seis_Nb_Trace,Total_Nb_Trace,Nb_Of_Dead_Seis_Chan
print HD
HDCnt=split(HD,HDArr,",")
NXTREC="Observer_Report"
HDCM=","HD","
}
{gsub (/[\t ]*|\*/, "", $1)}
$1 == NXTREC && PR {for (i=1; i<=HDCnt; i++) printf "%s,", RES[HDArr]
printf "%d\n", NR
delete RES
}
$1 == NXTREC {PR=1}
HDCM ~ "," $1 "," {T=$1; sub ($1 "[^:]*:[\t ]*", "", $0); sub (/[\t ]*$/, "", $0); RES[T]=$0}
END {for (i=1; i<=HDCnt; i++) printf "%s,", RES[HDArr]
printf "\n"
}
' OFS=":" /tmp/342
And, make sure you remove the DOS <CR> line separators!