def _clean_header(text: str, is_unit: bool = False) -> str:
    """
    Extract header text from each raw trajectory summary csv file header.

    :param text: Raw trajectory summary csv column header text.
    :param is_unit: If True, return text with brackets for units.

    :returns: Formatted text.
    """
    # Return an empty string if there is no header found
    if "Unnamed" in text:
        return ""

    # Removes additional spaces and hashtags from text. Add brackets optionally.
    clean_header = " ".join(text.replace("#", "").split())
    if is_unit:
        clean_header = f" ({clean_header})"

    return clean_header