HTML table generator

2008 October 25
tags: ,
by pythonisms

 keep it simple, simple but useful. Change the delimiter to a comma or whatever character desired in the line.split method.

a=open("input.txt")
b=open("output.html",'w')
qu=r'"'
b.write( "<html><h2>table</h2>")
b.write("<table cellpadding="+qu+"10px"+qu+" border="+qu+"2px"+qu+"><tr>")
for line in a:
    for word in line.split():
        b.write("<td>"+word+"</td>")
    b.write("</tr>")
b.write("</table></html>")
b.close()

One Response leave one →

Trackbacks & Pingbacks

  1. Primorials and primorial primes « Pythonism

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS