iode.Tables.__delitem__
- Tables.__delitem__(key)[source]
Remove the (subset of) table(s) referenced by key from the Tables database.
- Parameters:
- key: str or list(str)
(list of) name(s) of the table(s) to be removed. The list of names can be given as a string pattern (e.g. “A*;*_”).
Examples
>>> from iode import SAMPLE_DATA_DIR >>> from iode import tables >>> tables.load(f"{SAMPLE_DATA_DIR}/fun.tbl") Loading .../fun.tbl 46 objects loaded
>>> # a) delete one table >>> tables.get_names("G*") ['GAP', 'GDP', 'GFR', 'GFRLEVEL', 'GFRPC', 'GROWTH'] >>> del tables["GFRLEVEL"] >>> tables.get_names("G*") ['GAP', 'GDP', 'GFR', 'GFRPC', 'GROWTH']
>>> # b) delete several tables at once using a pattern >>> del tables["G*"] >>> tables.get_names("G*") []
>>> # c) delete several tables at once using a list of names >>> tables.get_names("C8_?") ['C8_1', 'C8_2', 'C8_3', 'C8_4', 'C8_5', 'C8_6', 'C8_7', 'C8_8', 'C8_9'] >>> del tables[["C8_1", "C8_3", "C8_5", "C8_7", "C8_9"]] >>> tables.get_names("C8_?") ['C8_2', 'C8_4', 'C8_6', 'C8_8']
>>> # delete one table from a subset of the global database >>> tables_subset = tables["M*"] >>> tables_subset.names ['MULT1FR', 'MULT1RESU', 'MULT2FR', 'MULT2RESU'] >>> del tables_subset["MULT2RESU"] >>> tables_subset.names ['MULT1FR', 'MULT1RESU', 'MULT2FR'] >>> # NOTE: the table has also been deleted from the global database >>> "MULT2RESU" in tables False >>> tables.get_names("M*") ['MULT1FR', 'MULT1RESU', 'MULT2FR']