def _get_cleaned_headers(headers):
 cleaned_headers = []
 for header in headers:
  sanitized = sub('^\\d+', '', sub('[\\W_]', '', header.lower()))
  if (len(sanitized) > 0):
   cleaned_headers.append(sanitized)
  else:
   raise GoogleSpreadsheetError(("Encountered a header '%s' that was either blank or consisted only of special characters. Could not map the header to the internal representation used by the Google Spreadsheet. Please change the header to consist of at least one alphanumeric character." % header))
 header_count = defaultdict(int)
 results = []
 for (header, cleaned_header) in zip(headers, cleaned_headers):
  new_header = cleaned_header
  if (header_count[cleaned_header] > 0):
   new_header = ('%s_%d' % (cleaned_header, (header_count[cleaned_header] + 1)))
  header_count[cleaned_header] += 1
  results.append(new_header)
 return results

def _get_cleaned_headers ( headers ) : cleaned_headers = [ ] for header in headers : sanitized = sub ( '^\\d+' , '' , sub ( '[\\W_]' , '' , header . lower ( ) ) ) if ( len ( sanitized ) > 0 ) : cleaned_headers . append ( sanitized ) else : raise GoogleSpreadsheetError ( ( "Encountered a header '%s' that was either blank or consisted only of special characters. Could not map the header to the internal representation used by the Google Spreadsheet. Please change the header to consist of at least one alphanumeric character." % header ) ) header_count = defaultdict ( int ) results = [ ] for ( header , cleaned_header ) in zip ( headers , cleaned_headers ) : new_header = cleaned_header if ( header_count [ cleaned_header ] > 0 ) : new_header = ( '%s_%d' % ( cleaned_header , ( header_count [ cleaned_header ] + 1 ) ) ) header_count [ cleaned_header ] += 1 results . append ( new_header ) return results
creates a list of "cleaned" headers which spreadsheets accept .