Thanks for your assistant.
This is my script, i want to obtain reports each half hour from file ope.log
My program LstToCsv2.awk
-----------------------
###first report
{
if(($1==1)&&(NF==7))
{
fecha=$6
hora=$7
print "first report"
opcion=1
}
if ((opcion==1)&&(NF==8)&&($1!="OG"))
{
printf"%s\t,%s\t\t,%s,%s,%s,%s,%s,%s,%s,%s\n",fecha,hora,$1,$2,$3,$4,$5,$6,$7,$8
{
###second report
if(($1==3)&&(NF==7))
{
fecha=$6
hora=$7
print "second report"
opcion=3
}
if((opcion==3)&&(NF==4)&&($1!="DEMAND"))
{
max_nf=NF
printf"%s\t,%s\t\t,", fecha,hora
for(i=1;i<=NF;i++)
{
nums[i,NR]=$i
printf "%s\t",nums[i,NR]
}
}
}
$1 ~ /END/{
for(x=1;x<=max_nf;x++){
printf "%s\t,%s\t\t,",fecha,hora
for(y=1;y<=NR;y++){
if(nums[x,y]!=""){
printf "%s\t\t,",nums[x,y]
}
}
print "\n"
}
}
file ope.log produce by a machine each half hour in the same file.
------------
#### begin first report
WO BOGOCEN CO24/1/ AT-5 TIME 040615 0928 PAGE 1
OPERATOR TRAFFIC RECORDING RESULTS 01
TRG MP NRP RPL RPN DATE TIME
1 8 12 30 7 040615 0900
OG ANO AT1PC AT2PC MTA HNO ALPVAL AUNB
GCNAL 353 98 100 3 168 79 14
GR192 259 95 100 3 123 89 11
GRCOD 37 78 86 8 22 78 2
##end first report
##begin second report
WO BOGOCEN CO24/1/ AT-5 TIME 040615 0928 PAGE 2
OPERATOR TRAFFIC RECORDING RESULTS 00
TRG MP NRP RPL RPN DATE TIME
3 8 12 30 7 040615 0900
CATY 191 199 NUM11
INCOMING CALLS
TOTINC 241 405 5
BRNO 4 15 0
ANO 234 390 5
AT1PC 98 96 60
AT2PC 100 100 100
MTA 3 3 6
OPBUSINC 0 0 0
BRWT 2 3 0
DEMAND AND DELAY CALLS
HNO 109 194 0
CANCELNO 125 184 4
DEMAND CALLS
DEMHNO 109 194 0
DEMOST 25 25 156
DEMCST 31 50 0
DELAY CALLS
DELQNO 0 0 0
DELHNO 0 0 0
DELOST 0 0 0
DELCST 0 0 0
QUEUE CALLS
QCALLSINC 39 47 3
QCONGINC 0 0 0
MQLINC 0.1 0.1 0.0
MQTIMEINC 3 5 3
QCALLSDL 0 0 0
QCONGDL 0 0 0
MQLDL 0.0 0.0 0.0
MQTIMEDL 0 0 0
QCALLSDMR 6 0 0
QCONGDMR 0 0 0
MQLDMR 0.0 0.0 0.0
MQTIMEDMR 2 0 0
QCALLSDLR 0 0 0
QCONGDLR 0 0 0
MQLDLR 0.0 0.0 0.0
MQTIMEDLR 0 0 0
END
##end second report
##first report
....TIME
09:30
###second report
......TIME
09:30
My script has a problem when it convert colums in rows for the second report, especially with the colum $4 it doesn`t print.
The script use a vector [] to convert colums in rows.
What happend I don`t know
some ideas.
Thanks again for your help
Malpa
This is my script, i want to obtain reports each half hour from file ope.log
My program LstToCsv2.awk
-----------------------
###first report
{
if(($1==1)&&(NF==7))
{
fecha=$6
hora=$7
print "first report"
opcion=1
}
if ((opcion==1)&&(NF==8)&&($1!="OG"))
{
printf"%s\t,%s\t\t,%s,%s,%s,%s,%s,%s,%s,%s\n",fecha,hora,$1,$2,$3,$4,$5,$6,$7,$8
{
###second report
if(($1==3)&&(NF==7))
{
fecha=$6
hora=$7
print "second report"
opcion=3
}
if((opcion==3)&&(NF==4)&&($1!="DEMAND"))
{
max_nf=NF
printf"%s\t,%s\t\t,", fecha,hora
for(i=1;i<=NF;i++)
{
nums[i,NR]=$i
printf "%s\t",nums[i,NR]
}
}
}
$1 ~ /END/{
for(x=1;x<=max_nf;x++){
printf "%s\t,%s\t\t,",fecha,hora
for(y=1;y<=NR;y++){
if(nums[x,y]!=""){
printf "%s\t\t,",nums[x,y]
}
}
print "\n"
}
}
file ope.log produce by a machine each half hour in the same file.
------------
#### begin first report
WO BOGOCEN CO24/1/ AT-5 TIME 040615 0928 PAGE 1
OPERATOR TRAFFIC RECORDING RESULTS 01
TRG MP NRP RPL RPN DATE TIME
1 8 12 30 7 040615 0900
OG ANO AT1PC AT2PC MTA HNO ALPVAL AUNB
GCNAL 353 98 100 3 168 79 14
GR192 259 95 100 3 123 89 11
GRCOD 37 78 86 8 22 78 2
##end first report
##begin second report
WO BOGOCEN CO24/1/ AT-5 TIME 040615 0928 PAGE 2
OPERATOR TRAFFIC RECORDING RESULTS 00
TRG MP NRP RPL RPN DATE TIME
3 8 12 30 7 040615 0900
CATY 191 199 NUM11
INCOMING CALLS
TOTINC 241 405 5
BRNO 4 15 0
ANO 234 390 5
AT1PC 98 96 60
AT2PC 100 100 100
MTA 3 3 6
OPBUSINC 0 0 0
BRWT 2 3 0
DEMAND AND DELAY CALLS
HNO 109 194 0
CANCELNO 125 184 4
DEMAND CALLS
DEMHNO 109 194 0
DEMOST 25 25 156
DEMCST 31 50 0
DELAY CALLS
DELQNO 0 0 0
DELHNO 0 0 0
DELOST 0 0 0
DELCST 0 0 0
QUEUE CALLS
QCALLSINC 39 47 3
QCONGINC 0 0 0
MQLINC 0.1 0.1 0.0
MQTIMEINC 3 5 3
QCALLSDL 0 0 0
QCONGDL 0 0 0
MQLDL 0.0 0.0 0.0
MQTIMEDL 0 0 0
QCALLSDMR 6 0 0
QCONGDMR 0 0 0
MQLDMR 0.0 0.0 0.0
MQTIMEDMR 2 0 0
QCALLSDLR 0 0 0
QCONGDLR 0 0 0
MQLDLR 0.0 0.0 0.0
MQTIMEDLR 0 0 0
END
##end second report
##first report
....TIME
09:30
###second report
......TIME
09:30
My script has a problem when it convert colums in rows for the second report, especially with the colum $4 it doesn`t print.
The script use a vector [] to convert colums in rows.
What happend I don`t know
some ideas.
Thanks again for your help
Malpa