Hi
Written some script to convert csv to html but could not add table headers.Below are the errors iam getting
./csv2html | more
+ awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white
BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\" bgcolor=\"%s\"\n>",border,bgcolor,width,fgcolor) "<th>" "Hostname" "</th>" "<th>" "Volstat" "</th>" "Pairstat" "</th>" }
{
print "<tr>";
for( i = 1 ; i <= NF ; ++i )
print "<td> "$i" </td>"
print "</tr>"
}
END { print "</table>" } /tmp/offshore/out/11.csv
awk: cmd. line:2: BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\" bgcolor=\"%s\"\n>",border,bgcolor,width,fgcolor) "<th>" "Hostname" "</th>" "<th>" "Volstat" "</th>" "Pairstat" "</th>" }
awk: cmd. line:2: ^ parse error
Scott
2
The error indicates, that the ) should be somewhere else:
... fgcolor) "<th>" ...
should be:
... fgcolor "<th>" "Hostname" "</th>" "<th>" "Volstat" "</th>" "Pairstat" "</th>")}
You should also use commas between the printf values:
fgcolor, "<th>", "Hostname", "</th>",...etc
Perhaps it would be simpler just to put the table header, etc in a printf on its own:
printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\" bgcolor=\"%s\"\n>",border,bgcolor,width,fgcolor)
printf("<th>Hostname</th><th>Volstat</th>Pairstat</th>\n")
Bulls eye thankyou mate its working now iam very much pleased
---------- Post updated at 11:55 PM ---------- Previous update was at 07:21 AM ----------
This thread is closed