获取嵌套表数据

时间:2020-01-21 08:52:44

标签: python excel list nested-table

我正在尝试从包含嵌套表的单词文档中提取数据到数据列表中,但是嵌套信息不会与其余数据一起进入数据列表。

def pdiesX(doc):
    dataList = []
    for table in doc.tables:
        for row in table.rows:
            for cell in row.cells:
                for paragraph in cell.paragraphs:
                    dataList.append(paragraph.text)
                    print(dataList)
                    data = paragraph.text + "\n"
                pdiesX(cell)

    row = 0
    col = 0
    for row, data in enumerate(dataList):
        worksheet.write(row, 0, data)                   
    row += 1

['1', '2', '3', '4', '', '6', '7', '8', '9']应该在下面显示的列表中

current output

0 个答案:

没有答案