Convert csv table to html using

How to convert CSV file to html table? I got the csv file with a comma "," and I want this file to be converted to an Html table.

+3
source share
2 answers

OK, do you really want it only in bash? Mission accomplished.

cat > input.csv
a,b,c
d,e,f
g,h,i

echo "<table>" ; while read INPUT ; do echo "<tr><td>${INPUT//,/</td><td>}</td></tr>" ; done < input.csv ; echo "</table>"
<table>
<tr><td>a</td><td>b</td><td>c</td></tr>
<tr><td>d</td><td>e</td><td>f</td></tr>
<tr><td>g</td><td>h</td><td>i</td></tr>
</table>

My first attempt used a "cat", but I thought it was a hoax, so I rewrote it using "while read"

+11
source

XmlGrid.net has a good tool for converting a CSV file to an HTML table. Link here: http://xmlgrid.net/csvToHtml.html

0
source

All Articles