Need to convert output.txt into html file

I have output.txt file generated through shell scripts which need convert in tabular format using html

can you please help me

output.txt

Token  State Date1   Date2             Description                                  Name
34567 open 27/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading init chadda,Deepak kumar 
45678 open 27/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading Sizing chadda,Deepak kumar 
43567 open 27/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading DBMS info chadda,Deepak kumar 
24578 open 28/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading Trig/Proc/Syn Sharma,Vijay Kumar 
51890 open 28/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading init Reddy,Ajay rao   

do you have tabs or space that delimit Description and Name ? With space delimiter, it gets difficult to distinguish where the description ends.

Space delimits the Description and Name...I have a file Namelist which contain all the names.....can we compare output.txt file with Namelist to distinguish Description and Name column..

cat Namelist
Sharma,Vijay Kumar
Soni,Amit Kumar
Rajput,Anupam 
chadda,Deepak kumar
Thakral,Raj Singhalese
Sahu,chanchal ram
Reddy,Ajay rao

Hi.

I have often used S Scholnick's perl code for this: T2t - text to table

Best wishes ... cheers, drl

You mentioned earlier that space delimits description and name but that is not going to help because space in description itself will cause problems.

So in order to avoid complexities always create an output with fields clearly separated by any delimiter.

Anyway try this awk program and see if it helps:

awk '
        BEGIN {
                print "<html>"
                print "<body>"
                print "<table border=1>"
        }
        NR == 1 {
                print "<tr>"
                for ( i = 1; i <= NF; i++ )
                        print "<td>" $i "</td>"
                print "</tr>"
        }
        NR > 1 {
                print "<tr>"
                for ( i = 1; i <= 4; i++ )
                        print "<td>" $i "</td>"
                l = match ( $0, /[a-zA-Z0-9]*-/ )
                n = match ( $0, /[a-zA-Z]*,/ )
                print "<td>" substr ( $0, l, n - l ) "</td>"
                print "<td>" substr ( $0, n ) "</td>"
                print "</tr>"
        }
        END {
                print "</table>"
                print "</body>"
                print "</html>"
        }
' file

now i will generate the output separated by delimiters.

This is working fine. Thanks a lot Yoda