Is it possible to convert the attached file to the format mentioned.
JObID,Tablename,Instancename,output rows,affected rows,applied rows,rejected rows
1,ABC,ABNC1,1085,1085,1085,0,1082,1082,1082,0
2,RAG,DGD,108,108,108,0,106,106,106,0
2,TAG,TYA,0,0,0,0,,,,,
3,FRE,TAR,,,,,2,2,2,0
Here for a particular job the table name and the corresponding instance name from one test run "X" is compared with the table name and the instance name from the second test run "Y" for output rows,affected rows,applied rows and rejected rows. The mismatching rows should be displayed in the format said above. If one table and a instance is present in either of the test runs then the format should be
2,TAG,TYA,0,0,0,0,,,,,
1,ABC,ABNC1,1085,1085,1085,0,1082,1082,1082,0
here 1 is the job name,ABC is the table name,ABNC1 is the instance name,"1085,1085,1085,0" are the values for output rows,affected rows,applied rows,rejected rows from X testrun and "1082,1082,1082,0" are the values for output rows,affected rows,applied rows,rejected rows from Y testrun.
Try this:
echo "JObID,Tablename,Instancename,output rows x,affected rows x,applied rows x,rejected rows x, output rows y,affected rows y,applied rows y,rejected rows y"
awk '
/^Summary/ { testrun=tolower($9) }
/^Job/ {
gsub("[][~(),]","") # strip out the unwanted characters
jobid=$3
table=$5
instance=$8
rowindex[jobid SUBSEP table SUBSEP instance]
output [jobid SUBSEP table SUBSEP instance SUBSEP testrun]=$11
affected[jobid SUBSEP table SUBSEP instance SUBSEP testrun]=$14
applied [jobid SUBSEP table SUBSEP instance SUBSEP testrun]=$17
rejected[jobid SUBSEP table SUBSEP instance SUBSEP testrun]=$20
}
END {
OFS=","
for (i in rowindex) {
split(i,a,SUBSEP)
jobid=a[1]
table=a[2]
instance=a[3]
print jobid,table,instance,
output [jobid SUBSEP table SUBSEP instance SUBSEP "x"],
affected[jobid SUBSEP table SUBSEP instance SUBSEP "x"],
applied [jobid SUBSEP table SUBSEP instance SUBSEP "x"],
rejected[jobid SUBSEP table SUBSEP instance SUBSEP "x"],
output [jobid SUBSEP table SUBSEP instance SUBSEP "y"],
affected[jobid SUBSEP table SUBSEP instance SUBSEP "y"],
applied [jobid SUBSEP table SUBSEP instance SUBSEP "y"],
rejected[jobid SUBSEP table SUBSEP instance SUBSEP "y"]
}
}
' inputfile | sort