I am trying to find the empty fields in a feature class and delete the fields.i am checking the number of empty or null rows are equal to total number of rows then i am deleting the field.i don't want to go throw all the rows and check field is empty or null.but many fields has spaces in the records i want to trim the spaces in string fields. i could not fingure it how to add trim function in SearchCursor where_clause or in sql_clause. could you please let me know how to do it.
result = arcpy.GetCount_management(layer)
totalRows = result[0]
if field.type == 'Double':
query = '("{0}" is null OR "{0}" = 0)'.format(field.name)
else:
query = '("{0}" is null or "{0}"=\'\')'.format(field.name) # query = '("{0}" is null or Trim("{0}")=\'\')'.format(field.name)
rows = [row for row in arcpy.da.SearchCursor(layer, [field.name], query)]
if int(totalRows) <= len(rows):
arcpy.DeleteField_management(layer, [field.name])