@ilwdchar_compat<EOL>def read_table(source, tablename=None, columns=None, contenthandler=None,<EOL>**kwargs):
from ligo.lw.ligolw import Document<EOL>from ligo.lw import (table, lsctables)<EOL>if Document.__module__.startswith("<STR_LIT>"):<EOL><INDENT>kwargs["<STR_LIT>"] = True<EOL><DEDENT>if tablename is not None:<EOL><INDENT>tableclass = lsctables.TableByName[<EOL>table.Table.TableName(tablename)<EOL>]<EOL>if contenthandler is None:<EOL><INDENT>contenthandler = get_partial_contenthandler(tableclass)<EOL><DEDENT>_oldcols = tableclass.loadcolumns<EOL>if columns is not None:<EOL><INDENT>tableclass.loadcolumns = columns<EOL><DEDENT><DEDENT>if isinstance(source, Document):<EOL><INDENT>xmldoc = source<EOL><DEDENT>else:<EOL><INDENT>if contenthandler is None:<EOL><INDENT>contenthandler = lsctables.use_in(LIGOLWContentHandler)<EOL><DEDENT>try:<EOL><INDENT>xmldoc = read_ligolw(source, contenthandler=contenthandler,<EOL>**kwargs)<EOL><DEDENT>finally:  <EOL><INDENT>if tablename is not None:<EOL><INDENT>tableclass.loadcolumns = _oldcols<EOL><DEDENT><DEDENT><DEDENT>if tablename is None:<EOL><INDENT>tables = list_tables(xmldoc)<EOL>if not tables:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if len(tables) > <NUM_LIT:1>:<EOL><INDENT>tlist = "<STR_LIT>".format("<STR_LIT>".join(tables))<EOL>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(tlist))<EOL><DEDENT>tableclass = lsctables.TableByName[table.Table.TableName(tables[<NUM_LIT:0>])]<EOL><DEDENT>return tableclass.get_table(xmldoc)<EOL>
Read a :class:`~ligo.lw.table.Table` from one or more LIGO_LW files

    Parameters
    ----------
    source : `Document`, `file`, `str`, `CacheEntry`, `list`
        object representing one or more files. One of

        - a LIGO_LW :class:`~ligo.lw.ligolw.Document`
        - an open `file`
        - a `str` pointing to a file path on disk
        - a formatted :class:`~lal.utils.CacheEntry` representing one file
        - a `list` of `str` file paths or :class:`~lal.utils.CacheEntry`

    tablename : `str`
        name of the table to read.

    columns : `list`, optional
        list of column name strings to read, default all.

    contenthandler : `~xml.sax.handler.ContentHandler`, optional
        SAX content handler for parsing LIGO_LW documents.

    **kwargs
        other keyword arguments are passed to `~gwpy.io.ligolw.read_ligolw`

    Returns
    -------
    table : :class:`~ligo.lw.table.Table`
        `Table` of data