'Python Docx - How check if each table contain more than 5 columns

I'm very new to programming in general,
Situation
Trying to create a script to open .docx file,
check for table,
if table has > 5 columns,
count the number of rows of those tables with > 5 columns.

Stuck
Stuck at how to check through each table automatically if it has > 5 columns,
and print out the number of rows in tables with > 5 columns

doctor = docx.Document()
doctor.tables
len(doctor.tables[0].columns)
len(doctor.tables[1].columns)
len(doctor.tables[2].columns)
len(doctor.tables[3].columns)
len(doctor.tables[4].columns)
len(doctor.tables[5].columns)

Background
Not all table in a word file holds the data I'm collecting, only table with > 5 columns will contain data I'm interested.
Using Docx library

1



Solution 1:[1]

doctor = docx.Document()
for table in doctor.tables:
    print(len(table.columns))
    if len(table.columns) > 5:
        # do something

Note that dealing with tables can be a challenge due to merged cells, etc.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1