ResSimpy.Nexus.nexus_file_operations.load_table_to_objects
- ResSimpy.Nexus.nexus_file_operations.load_table_to_objects(file_as_list: list[str], row_object: Any, property_map: dict[str, tuple[str, type]], current_date: str | None = None, unit_system: UnitSystem | None = None, nexus_obj_dict: dict[str, list[Any]] | None = None, preserve_previous_object_attributes: bool = False) list[tuple[Any, int]][source]
Loads a table row by row to an object provided in the row_object.
- Parameters:
file_as_list (list[str]) – file represented as a list of strings.
row_object (Any) – class to populate, should take a dictionary of attributes as an argument to the __init__
property_map (dict[str, tuple[str, type]]) – map of the Nexus keywords as keys to the dictionary and the names of the object attribute and the type of that attribute as a tuple in the values. e.g. {‘NAME’: (‘name’, str)} for the object obj with attribute obj.name
current_date (Optional[str]) – date/time at which the object was found within a recurrent file
unit_system (Optional[UnitSystem) – most recent UnitSystem enum of the file where the object was found
nexus_obj_dict (Optional[dict[str, list[Any]]]) – list of objects to append to. If None creates an empty list to populate.
preserve_previous_object_attributes (bool) – If True the code will find the latest object with a matching name attribute and will update the object to reflect the latest additional attributes and overriding all matching attributes. Must have a .update() method implemented and a name
- Returns:
list[obj] – list of tuples containing instances of the class provided for the row_object, populated with attributes from the property map dictionary and the line index where it was found