/usr/bin/awk has a limit for the printf string of 398 characters.
/usr/xpg4/bin/nawk has no limit.
Nawk to convert CSV file in HTML column/row format
nawk 'BEGIN{
FS=","
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Content-Disposition: inline"
print "<HTML>""<TABLE border="1"><TH>SA TEAM</TH><TH>Host Name</TH><TH>Host ID</TH><TH>User ID</TH><TH>Login Shell</TH><TH>GCOS Field</TH><TH>Data Source</TH><TH>Domain Name</TH><TH>Acct Status</TH><TH>Lock Type</TH>"
}
{
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
}
END{
print "</TABLE></BODY></HTML>"
}
' file-to-convert.csv > file.html
Wednesday, April 01, 2009
Nawk to convert CSV file in HTML column/row format
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment