Skip to content

LocalCSVCodelistFactory

Bases: LocalFileCodelistFactory

Deprecated : LocalCSVCodelistFactory has been replaced by LocalFileCodelistFactory for the creation of multiple codelists from a single CSV file. Use this class when you have a single CSV file that contains multiple codelists.

Source code in phenex/codelists/factory.py
class LocalCSVCodelistFactory(LocalFileCodelistFactory):
    """
    Deprecated : LocalCSVCodelistFactory has been replaced by LocalFileCodelistFactory for the creation of multiple codelists from a single CSV file. Use this class when you have a single CSV file that contains multiple codelists.
    """

    def __init__(self, **kwargs):
        warnings.warn(
            "LocalCSVCodelistFactory is deprecated and will be removed in a future release. Please use LocalFileCodelistFactory instead.",
            DeprecationWarning,
        )
        super(LocalCSVCodelistFactory, self).__init__(**kwargs)

get_codelist(name)

Retrieve a single codelist by name.

Source code in phenex/codelists/factory.py
def get_codelist(self, name: str) -> Codelist:
    """
    Retrieve a single codelist by name.
    """
    try:
        df_codelist = self.df[self.df[self.name_codelist_column] == name]
        code_dict = (
            df_codelist.groupby(self.name_code_type_column)[self.name_code_column]
            .apply(list)
            .to_dict()
        )
        return Codelist(name=name, codelist=code_dict)
    except:
        raise ValueError("Could not find the codelist with the given name.")

get_codelists()

Get a list of all codelists in the supplied CSV.

Source code in phenex/codelists/factory.py
def get_codelists(self) -> List[str]:
    """
    Get a list of all codelists in the supplied CSV.
    """
    return self.df[self.name_codelist_column].unique().tolist()