def asFloatOrNone(val):
    """Converts floats, integers and string representations of either to floats.
    If val is "NaN" (case irrelevant) or "?" returns None.

    Raises ValueError or TypeError for all other values

    """
    if hasattr(val, 'lower') and val.lower() in ('nan', '?'):
        return None
    else:
        return float(val)
