def safe_convert(s, default=0):
    """
    Converts something to a float. If an error occurs, returns the default value.
    """
    try:
        v = float(s)
    except ValueError:
        v = default
    return v