import string


def MakeValidTableName(name):
  """Turn name string into a valid bigquery table name.

  Table names (or tableId) can be any letter or number or _ but cannot
  start with a number.

  Args:
    name: the table name you wish to sanitize.
  Returns:
    a sanitized version of name with only letters, digits or _
  """
  allowed_characters = string.ascii_letters + string.digits + '_'
  name = ''.join(x for x in name if x in allowed_characters)
  if not name or name[0] in string.digits:
    name = '_' + name
  return name