使用将csv转换为html表 [英] Convert csv to html table using
本文介绍了使用将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"
这篇关于使用将csv转换为html表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文