import csv


def load_entities_from_csv(csv_filepath: str, model) -> dict:
    """Load entities from csv file

    :param csv_filepath: string csv file path
    :param model: either str or class
    :return: dict of entities
    """
    with open(csv_filepath, 'r', encoding='utf-8') as file:
        source_data = list(
            map(dict, csv.DictReader(file, skipinitialspace=True)))
        if isinstance(model, str):
            model_name = model
        else:
            model_name = '.'.join([model.__module__, model.__name__])

        entities = {'model': model_name, 'data': source_data}

    return entities