@ilwdchar_compat<EOL>def table_to_ligolw(table, tablename):
from ligo.lw import lsctables<EOL>columns = table.columns.keys()<EOL>cls = lsctables.TableByName[tablename]<EOL>llwcolumns = list(columns)<EOL>for col, llwcols in _get_property_columns(cls, columns).items():<EOL><INDENT>idx = llwcolumns.index(col)<EOL>llwcolumns.pop(idx)<EOL>for name in llwcols[::-<NUM_LIT:1>]:<EOL><INDENT>llwcolumns.insert(idx, name)<EOL><DEDENT><DEDENT>llwtable = lsctables.New(cls, columns=llwcolumns)<EOL>for row in table:<EOL><INDENT>llwrow = llwtable.RowType()<EOL>for name in columns:<EOL><INDENT>setattr(llwrow, name,<EOL>to_ligolw_table_type(row[name], llwtable, name))<EOL><DEDENT>llwtable.append(llwrow)<EOL><DEDENT>return llwtable<EOL>
Convert a `astropy.table.Table` to a :class:`ligo.lw.table.Table`