Parsing of Char and Numeric in a file

Hi All,

i'm working on some report and currently have this plain text file generated.

server_name1|sdfd1deal      |        1048572|        1040952|    99|      207|        1|       1
server_name1|dba1dbs        |       83886048|       40730796|    48|     5762|    22764|       8
server_name1|dbsd1phpal     |      503316320|       38609208|    07|     1087|      535|      40
server_name1|dbsd1dbsdl     |      199229388|       59869752|    30|      120|     6322|      13
server_name1|dbsd1deal      |      534773604|       50339708|    09|     8048|    21015|      39
server_name1|dbsd1eal       |      511704944|       84434568|    16|      524|      386|      36
server_name1|dbsd2dbsdl     |       94371828|       31457264|    33|       24|        4|       3
server_name1|dbsd3dbsdl     |      125829104|       27361264|    21|       27|        5|       4
server_name1|dbsd4dbsdl     |      157286380|       69732856|    44|       35|      364|       5
server_name1|dbsd5dbsdl     |       62914552|       36914328|    58|       11|        3|       2
server_name1|rootdbs1       |        2097148|        2072792|    98|     1116|    36319|       1

I want to convert it into HTML and got this code.

  {print "<tr>"
    for(i=1;i<=NF;i++)
        print "<td>" $i"</td>"
    print "</tr>"

My problem is the numeric columns shows left justified. I want all the columns to be right justified.

thanks in advance for anyone who can help.

This is currently in AIX, using ksh shell.

Fe

The easiest is to add CSS style once

<!DOCTYPE html>
<html>
<head>
<tittle>"Title Here"</title>
<style>
td { text-align:right; }
</style>
</head>

or to add at each td

"<td align=\"right\">"$i"</td>"; 

Thanks.. i stand corrected.

Here's what i want...

String values should be left justified.
Numeric values should be right justified.

It's working, but the "String" values are also now right justified instead of Left justified.

awk -F"|" '
    BEGIN{
        tda="<td align=\"right\">"
        tdo="<td>"
        tdc="</td>"
        
    }
    {
        print "<tr>"
        for(i=1;i<=NF;i++)
            print (($i == $i+0) ? tda : tdo) $i tdc
        print "</tr>"
    }
' fedora132010.file

Thank you very much. It's working now.