import string


def clean_tablename(name):
    """Accepts a name, and returns with whitespace replaced by
    underscores and any other non-alphanumeric characters removed."""
    no_whitespace = str.maketrans(string.whitespace + '.' + '-',
                                  '_'*(len(string.whitespace)+2))
    name = name.translate(no_whitespace)
    return ''.join(char for char in name if char.isalnum() or char == '_')