# ### ctable.sh ### ### Convert *.csv file to *.html file ### with data in table format ### ### ### Usage ctable.sh filename.csv ### ### ### Note: ### ### Before dumping from Excel, change all commas (,) ### to pipes (|) doing a search and replace. ### After running this script, change pipes back ### to commas. ### ### x=`basename $1 .csv` echo "<html>" > $x.html echo "<head>" >> $x.html echo "<title> $x </title>" >> $x.html echo "</head>" >> $x.html echo "<body>" >> $x.html echo "<center>" >> $x.html echo "<p>&nbsp;</p>" >> $x.html echo "<h1> $x </h1>" >> $x.html echo "<p>&nbsp;</p>" >> $x.html echo "<p><blockquote>" >> $x.html echo "<table cellpadding=4 border=1>" >> $x.html sed "s/^/ <td valign=top>/g" $1 | \ sed "s/^/<tr>/g" $y | \ sed "s/,/<\/td> <td valign=top>/g" | \ sed "s/$/<\/td>/g" | \ sed "s/|/,/g" $y | \ sed "s/$/<\/tr>/g" | \ sed "s/top></top><br></g" >> $x.html echo "</center>" >> $x.html echo "</table>" >> $x.html echo "</blockquote>" >> $x.html echo "</body>" >> $x.html echo "</html>" >> $x.html