import re


def fix_name(name):
    """ Fix the names so that they are valid python variable names """
    name = name.lower()
    name = re.sub(r'[^a-z0-9_]+', '_', name).strip('_')
    name = re.sub(r'[_]+', '_', name)
    name = re.sub(r'^[0-9_]+', '', name)

    return name