iode.Database.copy_from

Note

Below, Database represents either:

  • Comments

  • Equations

  • Identities

  • Lists

  • Scalars

  • Tables

  • Variables

Database.copy_from(self, input_files: str | List[str], objects_names: str | List[str] = '*')

Copy (a subset of) objects from the input file(s) ‘input_files’ into the current database.

Parameters:
input_file: str or list(str)

file(s) from which the copied objects are read.

objects_names: str or list(str)

list of objects to copy from the input file(s). Defaults to load all objects from the input file(s).

Examples

>>> from iode import SAMPLE_DATA_DIR
>>> from iode import comments
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
>>> len(comments)
317
>>> # delete all comments with a name starting with 'A'
>>> comments.remove("A*")
>>> comments.get_names("A*")
[]
>>> # load all comments with a name starting with 'A'
>>> comments.copy_from(f"{SAMPLE_DATA_DIR}/fun.cmt", "A*")
>>> comments.get_names("A*")
['ACAF', 'ACAG', 'AOUC', 'AQC']
>>> comments.clear()
>>> # load all comments
>>> comments.copy_from(f"{SAMPLE_DATA_DIR}/fun.cmt")
>>> len(comments)
317