Problems with HTMLgen tables
Thomas A. Bryan
tbryan at python.net
Thu May 4 14:37:23 CEST 2000
"Martin Skøtt" wrote:
> Can you help me solve the problem? (Red Hat 5.2, Python 1.5.1)
> #!/usr/bin/env python
> import string, HTMLgen
> data = 'netstats/data.dat'
> fil = open(data, 'r')
> fila = fil.readlines()
> doc = HTMLgen.SimpleDocument(title='Interface statistik for ppp0')
> table = HTMLgen.Table()
> table.body = 
> for line in fila:
> inf = string.strip(line)
The problem is in the line that reads
inf = string.strip(line)
You probably want
inf = string.split(line) # this makes the most sense to me
inf = [string.strip(line)]
You could also fix the problem at the point where you
append to the table.body.
The table.body is a list of lists. Each list in
table.body is a (table) row. Each element of the nested
lists is a (table data) column in that row.
You were appending plain strings returned by string.strip.
More information about the Python-list