def str2num(string, decimal_sep='.'):
    """
    A helper function that converts strings to numbers if possible
    and replaces the float decimal separator with the given value.
    eg. '1' => 1
        '1.2' => 1.2
        '1,2' => 1.2
        'True' => True
    """
    if not isinstance(string, str): return string
    if string.isdigit(): return int(string)
    if string=='True': return True
    if string=='False': return False
    try: 
        string_x = string.translate({ord(decimal_sep): 46})
        # necessary because of PEP-515, ignore _ in strings
        string_x = string_x.translate({95:35})
        return float(string_x)
    except: return string