from pathlib import Path


def to_condition(p: Path, ind: int = -1, sep: str = "_") -> list:
    """
    converts path into a row for condition dataframe
    it assumes that the names of the files have pars separated by "_" or other separator
    :param p path to the file
    :param ind where in a splited file name to search for condition
    :param sep separator in the file name, _ by default
    :rtype: list
    """
    split = p.stem.split(sep)
    last = split[ind]
    if last.find("(") == -1 or last.find(")") == -1:
        return [last, 0, p, True]
    else:
        start = last.index("(")
        end = last.index(")")
        num = last[start+1:end].strip()
        return [last[0:start].strip(), num, p, False]