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']
>>> # store a table in a Python variable
>>> tbl = tables["MULT1FR"]
>>> tbl
DIVIS | 1                                              |
TITLE |         "Principaux indicateurs : montants absolus"
----- | -----------------------------------------------------------
CELL  | " "                                            | "#s"
----- | -----------------------------------------------------------
CELL  | "1. Demande globale"                           |
CELL  | "       Consommation privée"                   |         QC
CELL  | "       Consommation publique"                 |         QG
CELL  | "       Formation brute de capital fixe"       |         QI
CELL  | "            - Entreprises"                    |        QIF
CELL  | "            - Etat"                           |        QIG
CELL  | "            - Logements"                      |        QI5
CELL  | "       Exportations de biens et services"     |         QX
CELL  | "       Importations de biens et services"     |         QM
CELL  | "       Produit Intérieur Brut"                |       QBBP
CELL  | "       Produit National Brut"                 |       QBNP
CELL  | "2. Marché du travail"                         |
CELL  | "       Emploi total"                          |    NATY-UY
CELL  | "         Entreprises"                         |    NFY+NIY
CELL  | "         Etat"                                |        NGY
CELL  | "3. Prix, salaires et revenus"                 |
CELL  | "       Salaire coût horaire"                  |       WCRH
CELL  | "       Salaire coût réel horaire"             |    WCRH/PC
CELL  | "       Déflateur de la consommation privée"   |         PC
CELL  | "       Coûts salariaux unitaires (apparents)" |  WCRH/PROD
CELL  | "       Coûts salariaux unitaires (techn.)"    |    WCRH/QL
CELL  | "       Prix des importations"                 |         PM
CELL  | "       Coûts totaux par unité produite "      |       AOUC
CELL  | "       Prix des exportations de biens"        |       PXAB
CELL  | "       Termes de l'échange (PX/PM)"           |      PX/PM
CELL  | "       Revenu disponible réel des ménages"    |     YDH/PC
CELL  | "4. Entreprises"                               |
CELL  | "       Valeur ajoutée (prix constants)"       |       QAF_
CELL  | "       Déflateur de la valeur ajoutée"        |       PAF_
CELL  | "       Valeur ajoutée potentielle"            |        Q_F
CELL  | "       Stock de capital"                      |       KNFY
CELL  | "5. Productivités du travail"                  |
CELL  | "       Productivité horaire apparente"        |       PROD
CELL  | "       Productivité horaire technique"        |         QL
CELL  | "       Productivité par tête "                | QAF_/(NFY)
----- | -----------------------------------------------------------
MODE  |
FILES |
DATE  |

nb lines: 43
nb columns: 2
language: 'ENGLISH'
gridx: 'MAJOR'
gridy: 'MAJOR'
graph_axis: 'VALUES'
graph_alignment: 'LEFT'

>>> # then delete it from the database
>>> del tables["MULT1FR"]
>>> "MULT1FR" in tables
False
>>> # NOTE: the Python variable 'tbl' still contains the table object
>>> tbl
DIVIS | 1                                              |
TITLE |         "Principaux indicateurs : montants absolus"
----- | -----------------------------------------------------------
CELL  | " "                                            | "#s"
----- | -----------------------------------------------------------
CELL  | "1. Demande globale"                           |
CELL  | "       Consommation privée"                   |         QC
CELL  | "       Consommation publique"                 |         QG
CELL  | "       Formation brute de capital fixe"       |         QI
CELL  | "            - Entreprises"                    |        QIF
CELL  | "            - Etat"                           |        QIG
CELL  | "            - Logements"                      |        QI5
CELL  | "       Exportations de biens et services"     |         QX
CELL  | "       Importations de biens et services"     |         QM
CELL  | "       Produit Intérieur Brut"                |       QBBP
CELL  | "       Produit National Brut"                 |       QBNP
CELL  | "2. Marché du travail"                         |
CELL  | "       Emploi total"                          |    NATY-UY
CELL  | "         Entreprises"                         |    NFY+NIY
CELL  | "         Etat"                                |        NGY
CELL  | "3. Prix, salaires et revenus"                 |
CELL  | "       Salaire coût horaire"                  |       WCRH
CELL  | "       Salaire coût réel horaire"             |    WCRH/PC
CELL  | "       Déflateur de la consommation privée"   |         PC
CELL  | "       Coûts salariaux unitaires (apparents)" |  WCRH/PROD
CELL  | "       Coûts salariaux unitaires (techn.)"    |    WCRH/QL
CELL  | "       Prix des importations"                 |         PM
CELL  | "       Coûts totaux par unité produite "      |       AOUC
CELL  | "       Prix des exportations de biens"        |       PXAB
CELL  | "       Termes de l'échange (PX/PM)"           |      PX/PM
CELL  | "       Revenu disponible réel des ménages"    |     YDH/PC
CELL  | "4. Entreprises"                               |
CELL  | "       Valeur ajoutée (prix constants)"       |       QAF_
CELL  | "       Déflateur de la valeur ajoutée"        |       PAF_
CELL  | "       Valeur ajoutée potentielle"            |        Q_F
CELL  | "       Stock de capital"                      |       KNFY
CELL  | "5. Productivités du travail"                  |
CELL  | "       Productivité horaire apparente"        |       PROD
CELL  | "       Productivité horaire technique"        |         QL
CELL  | "       Productivité par tête "                | QAF_/(NFY)
----- | -----------------------------------------------------------
MODE  |
FILES |
DATE  |

nb lines: 43
nb columns: 2
language: 'ENGLISH'
gridx: 'MAJOR'
gridy: 'MAJOR'
graph_axis: 'VALUES'
graph_alignment: 'LEFT'