iode.Table.index
- Table.index(key: str) int[source]
Return the index of the line containing the string key.
- Parameters:
- key: str
Text to be retrieved either as a title or as a cell content.
- Returns:
- int
Examples
>>> from iode import SAMPLE_DATA_DIR >>> from iode import Table, comments, lists, variables >>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt") Loading .../fun.cmt 317 objects loaded >>> lists.load(f"{SAMPLE_DATA_DIR}/fun.lst") Loading .../fun.lst 17 objects loaded >>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var") Loading .../fun.var 394 objects loaded >>> table_title = "Table example" >>> lines_titles = ["GOSG:", "YSSG+COTRES:", "OCUG:"] >>> lines_lecs = ["GOSG", "YSSG+COTRES", "OCUG"] >>> table = Table(2, table_title, lines_lecs, lines_titles, True, True, True) >>> table DIVIS | 1 | TITLE | "Table example" ----- | ---------------------------- CELL | | "#S" ----- | ---------------------------- CELL | "GOSG:" | GOSG CELL | "YSSG+COTRES:" | YSSG+COTRES CELL | "OCUG:" | OCUG ----- | ---------------------------- MODE | FILES | DATE | nb lines: 11 nb columns: 2 language: 'ENGLISH' gridx: 'MAJOR' gridy: 'MAJOR' graph_axis: 'VALUES' graph_alignment: 'LEFT'
>>> table.index("Table example") 0 >>> table.index("GOSG:") 4 >>> table.index("OCUG") 6