使用将csv转换为html表

问题描述:

如何将CSV文件转换为html表?我得到了一个带有逗号,"的csv文件,并且希望将此文件转换为HTML表.

How can I convert a CSV file into html table? I got a csv file with comma "," and I want this file to convert to Html table.

好吧,您真的只想要bash吗?任务完成了.

OK, 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 try used "cat" but I figured that was cheating, so I rewrote it using "while read"