July 12th, 2004, 03:44 PM
Printing Table Data
I always find myself printing data in tables. Does anyone know of a cool script that I can use that would automatically print out the data in a table in a formatted way, html-zied or not? Thanks!
July 14th, 2004, 05:40 AM
table = get_table()
for r in table:
for c in r:
July 14th, 2004, 06:59 AM
Please use code tags in future, also, read the sticky regarding how to post!
This will work fine - the spaces here are simply to indent the HTML for easy reading, if that doesnt matter to you just remove any white space at the beginning of the print statments.
table = ((1, 2, 3), (4, 5, 6))
for row in table:
print ' <tr>'
for col in row: print ' <td>%s</td>' % col
print ' </tr>'
Remember, you'll have to make sure that each row contains the same number of columns or you're table will break!
July 22nd, 2004, 07:46 PM
Thanks for the reply guys! I will try them out as soon as I can.