Hello, I am new to Python and have a mission impossible to a beginner, I need to import a specific table from a source code written in LaTex. I tried to start this code in this way :

import asciitable
from sys import argv


def searching_table(table_identifier):
    with open(fname, "r") as fin:
        mylist = []
        for line in fin:
            line = line.rstrip()
            if table_identifier in line:
                if "begin{tabular}" in line
                    mylist.append(line)
                    if "\end{tabular}" in line

Is there any way simpler than that to do this job?