Feb 21, 2012

How to convert an CSV file to HTML




The simplest was to do this so that it can run in any explorer is to convert the csv file to html using following command
nawk 'BEGIN{
FS=","
print  "< HTML >""< TABLE border="1" >" 
}
 {
printf "< TR >"
for(i=1;i< =NF;i++)
printf "< TD >%s< /TD >", $i
print "< /TR >"
 }
END{
print "< /TABLE >< /BODY >< /HTML >"
 }
' k.csv > k.html

where k.csv file is the input file
and k.html is output file

No comments: