def _str_to_int_or_float(val):
    """helper function that tries to cast a str to int and if that fails then tries casting to float"""
    try:
        val = int(val)
    except ValueError:
        val = float(val)
    return val