iode.Comments.copy_from

Comments.copy_from(input_files: str | List[str], names: str | List[str] = '*')[source]

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

Parameters:
input_file: str or list(str)

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

names: str or list(str)

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

Examples

>>> from iode import SAMPLE_DATA_DIR
>>> from iode import comments
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
Loading .../fun.cmt
317 objects loaded 
>>> 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*")
Loading ...fun.cmt
317 objects loaded
4 comment read from file '...fun.cmt'
>>> comments.get_names("A*")
['ACAF', 'ACAG', 'AOUC', 'AQC']
>>> comments.clear()
>>> # load all comments
>>> comments.copy_from(f"{SAMPLE_DATA_DIR}/fun.cmt")
Loading ...fun.cmt
317 objects loaded 
317 comment read from file '...fun.cmt' 
>>> len(comments)
317