def split_conn_PFI(connection):
    """Return PFI input number of a connection string such as 'PFI0' as an
    integer, or raise ValueError if format is invalid"""
    try:
        return int(connection.split('PFI', 1)[1])
    except (ValueError, IndexError):
        msg = "PFI connection string %s does not match format 'PFI<N>' for integer N"
        raise ValueError(msg % str(connection))