Convert CSV to a HTML table format and store in a HTML file

后端 未结 3 1514
难免孤独
难免孤独 2020-12-22 06:08

I have tried few shell scripts to convert to a HTML table format but I didnt get desired output. Could anyone help here to convert CSV to a HTML table format using Python or

3条回答
  •  醉话见心
    2020-12-22 06:40

    well, I think that the easiest way to do it is.

    import pandas as pd
    
    csv = pd.read_csv('csv_file.csv')
    html_table = csv.to_html()
    
    f = open('html_file.html', 'w')
    f.write(html_table)
    f.close()
    

    try it out!

提交回复
热议问题