def _to_number(value):
    """Convert a string to a numeric.

    The returned value is either an int or a float, depending on the input.
    Raises a ValueError if the value cannot be parsed.
    """
    try:
        num = int(value)
    except ValueError:
        num = float(value)
    return num
