import csv


def get_params(file, numerical_key=False):
    """
    Function to create a dictionary from a .csv file.

    Parameters
    ----------
    file : _io.TextIOWrapper
        csv file
    numerical_key : bool, optional
        numerical key, by default False

    Returns
    -------
    dict
        Dictionary of parameters.
    """
    d_params = {}
    with open(file) as params:
        rows = csv.reader(params)
        next(rows)
        for row in rows:
            var, value, var_type, _ = row
            if var_type == 'int':
                d_params[var] = int(value)
            elif var_type == 'float':
                d_params[var] = float(value)
            elif var_type == 'bool':
                d_params[var] = bool(int(value))
            else:
                d_params[var] = value
    if numerical_key:
        d_params = {int(k): v for k, v in d_params.items()}
    return d_params