Re: comple list slices
- From: William Meyer <wmmeyer@xxxxxxxxx>
- Date: Tue, 28 Feb 2006 16:26:52 +0000 (UTC)
<shandy.b <at> gmail.com> writes:
A couple questions:
1- what is j?
2- what does the rows[x][y] object look like? I assume it's a dict
that has a "rowspan" key. Can rows[x][y]["rowspan"] sometimes be 0?
Perhaps you're looking for something like this:
rowgroups = []
rowspan = 0
for i in range( len(rows) ):
if rowspan <= 0:
rowspan = rows[j][0]["rowspan"]
if rowspan == 0:
rowspan = 1
rowgroups.append(rows[ i : i + rowspan ])
rowspan -= 1
-sjbrown
oops, typo
row[j] should be i
that line should read:
rowspan = i[0]["rowspan"]
rows is a list of lists which contains td tag objects from beautifulsoup.
rowspan is a tag attribute. You solution is clearer then mine, but the approach
is the same. Is there finer grained control of loops in python? (or in a perfect
world a way to group rows this way with list comprehensions?)
Rowspan can be none, meaning 1, and it can be zero. Zero means the row extends
from the current cell until the end of the table. That isnt used much, and not
in the table I am scraping at all.
.
- References:
- comple list slices
- From: William Meyer
- Re: comple list slices
- From: shandy . b
- comple list slices
- Prev by Date: Re: Vectorization and Numeric (Newbie)
- Next by Date: Re: comple list slices
- Previous by thread: Re: comple list slices
- Next by thread: Re: comple list slices
- Index(es):