extract text from ods TableCell using odfpy
frankentux
cfarrell1980 at googlemail.com
Tue Aug 26 04:08:31 EDT 2008
Ok. Sorted it out, but only after taking a round trip over
xml.minidom. Here's the working code:
#!/usr/bin/python
from odf.opendocument import Spreadsheet
from odf.opendocument import load
from odf.table import TableRow,TableCell
from odf.text import P
doc = load("/tmp/match_data.ods")
d = doc.spreadsheet
rows = d.getElementsByType(TableRow)
for row in rows[:2]:
cells = row.getElementsByType(TableCell)
for cell in cells:
tps = cell.getElementsByType(P)
if len(tps) > 0:
for x in tps:
print x.firstChild
More information about the Python-list
mailing list