def convert_val(val_str, val):
    """ Given a string, convert into the correct data type """
    if val is bool:
        if 'true' in val_str.lower(): val_str = 'true' 
        else: val_str = '' # otherwise set to false
    val_type = val
    try:
        return val_type(val_str)
    except ValueError:
        # Can it be a float ?
        return val_type(float(val_str))