python read single or multiple table content data in word documents

python read single or multiple table content data in word documents

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import docx
from docx import Document

docs = Document("test.docx")
tables = docs.tables
for n in range(1, len(tables)):
    table = tables[n - 1]
    for i in range(1, len(table.rows)):
        row0 = table.cell(i, 0).text
        row1 = table.cell(i, 0).text
        row2 = table.cell(i, 1).text
        row3 = table.cell(i, 2).text
        row4 = table.cell(i, 3).text
        print('%s,%s,%s,%s,%s' %(row0, row1, row2, row3, row4))

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example