def _trim_columns(columns, max_columns):
  """Prints a warning and returns trimmed columns if necessary."""
  if len(columns) <= max_columns:
    return columns
  print(('Warning: Total number of columns (%d) exceeds max_columns (%d)'
         ' limiting to first max_columns ') % (len(columns), max_columns))
  return columns[:max_columns]