Save log data in excel sheet

Hello,

I have the following data format in a log file :

a : x1
b : x2
c : x3
d : x4
--------
a : x5
b : x6
c : x7
d : x8

so the same fields ( a ,b ,c,d) repeated many times in the same log file but with different "x" values (x5,x6,x7,x8).

I need a script to save this data in an excel sheet in the following format:

a        b      c      d
x1       x2     x3    x4
x5       x6     x7    x8

Thanks in advance....

Excel can understand CSV files natively, so all you need is this:

awk -F":" '{ A[$1]=A[$1]","$2 } END { for(X in A) print X A[X] "\r" }' inputfile > output.csv

Try also:

awk     '/------/       {next}
                        {hd[$1]++
                         ln[hd[$1],$1]=$3}
         END            {for (i in hd) printf "%s,", i; printf "\n"
                         while (n++ < hd[$1]) {for (i in hd) printf "%s,", ln[n,i]; printf "\n"}
                        }
        ' file
a,b,c,d,
x1,x2,x3,x4,
x5,x6,x7,x8,

Many thanks for your replies
the problem with these scripts is that if x value is more than one word the script will not display the full line.so if for example x1 is "hello word" the above scripts will display "hello" only.

awk   -F :  '/------/       {next}
                        {hd[$1]++
                         gsub(/^ */,"",$2);ln[hd[$1],$1]=$2}
         END            {for (i in hd) printf "%s,", i; printf "\n"
                         while (n++ < hd[$1]) {for (i in hd) printf "%s,", ln[n,i]; printf "\n"}
                        }
        ' infile

Another awk

awk 'NR%5 {printf "%s ",$3;next}1'

@Jotne: this works if there's always 4 data lines. My approach tries to allow for more data lines. I'm sure, though, that it deserves quite some polishing, still.
@rdcwayx: thanks for adapting to the requestors NEW specification!