I have a file that is large and is broken up by groups of data. I want to take certain fields and display them different to make it easier to read. Given input file below:
2008 fl01 LAC 2589 polk doal
xx 2008q1 mx
sect 25698541
Sales 08 Dept group
lead1 2008q1
tom
pat
tim
tad
lead1 07q4 07q3 07q2 07q1 06q4 06q3 jan
tom 0 96 0 3312 3624 0 312
pat 0 17 0 0 30 0 30
tim 357 03 04 25 3020 3120 20
tad 1734 0 0 0 5213 5213 0
lead1 feb mar apr may jun jul aug
tom 0 96 0 0 0 0 0
pat 0 17 0 0 0 0 0
tim 357 23 5 7 8 14 70
tad 1734 0 0 0 0 0 0
lead1 sept oct nov dec
tom 0 0 460 92
pat 0 0 240 0
tim 0 21 1800 0
tad 0 0 672 0
2008 fl01 LAC 2589 polk doal
yy 2008q1 mx
sect 2569852
Sales 08 Dept group
I would like to display:
lead1 07q4 07q1 06q4 06q3 sept oct nov
tim 357 25 3020 3120 0 21 1800
tad 1734 0 5213 5213 0 0 672
Can anyone help out on this? I can't seem to get this right.
Thanks in advance.
I don't understand your question. But I wanted the input file to print out differently. Problem I was having was that the id are slit between blank lines and data I wanted to parse have different NF. I was trying awk and going the route of arrays with no luck, because while some records I want $2 on other records $2 might be a field I don't want.
Can someone check my code below and help me fix? I can't seem to get this right. I am stuck, any help in making this easier for me, I would really appreciate it.
thanks
$3 ~ /mx$/ && !s12 {
printf "sales dept 08 %s %s\n",time,date
print "-----------------"
print "lead1 07q4 07q3 07q2 07q1 06q4 06q3 jan nov dec"
s12++
}
s12 {
if ( $5 ~ /07q1/ ) {
f1++
}
if ( f1 ) {
s1[$1"_ld "]=$1 ; s1[$1"_7q4 "]=$2 ; s1[$1"_7q3 "]=$3
s1[$1"_7q2 "]=$4; s1[$1"_7q1 "]=$5 ; s1[$1"_6q4 "]=$6
s1[$1"_6q3 "]=$7 ; s1[$1"_jan "]=$8
for ( i in s1 ) { printf "|%s",i s1 }
}
if ( ! NF ) {
f1=""
}
if ( $5 ~ /dec$/ ) {
f3++
}
if ( f3 ) {
s3[$1"_nov "]=$4 ; s3[$1"_dec "]=$5
for ( i in s3 ) { printf "|%s",i s3 }
}
if ( ! NF ) {
f3=""
}
if ( $3 ~ /my/ ) {
print "\n"
f3=s12=""
}
}
summer,
thanks soo much for looking into this. I really appreciate it. I should have been more specific on what I needed. I still think this will help a lot. I was looking for a awk solution, because I was having issues with this part of the script/function. Your solution I believe will help me with this part of the script I am writing. Thanks again soo much.