AnsweredAssumed Answered

Unable to set a where clause using <> '   ' in a Python 3.x script

Question asked by aroust on Sep 15, 2020
Latest reply on Sep 16, 2020 by aroust

Totally stumped. I have a few records in a table that I imported into a file geodatabase from Excel that have three blank spaces in a text field called Specialty_Code instead of the required three character code. I want my script to skip those records in the analysis, so I'm creating a table view that excludes those records.

 

Using Python 3.x, why does this work (line 3)....

 

    allRecords = defaultGDB + '\\CleanTable_' + fileName
    outLayer = 'CleanTable_' + fileName + '_View'
    defQuery = "Specialty_Code IS NOT NULL"
    print(defQuery)
    readyToAppend = arcpy.MakeTableView_management(allRecords, outLayer, defQuery)

 

... but this doesn't (line 3)?

 

    allRecords = defaultGDB + '\\CleanTable_' + fileName
    outLayer = 'CleanTable_' + fileName + '_View'
    defQuery = "Specialty_Code IS NOT NULL and Specialty_Code <> \'   \'"
    print(defQuery)
    readyToAppend = arcpy.MakeTableView_management(allRecords, outLayer, defQuery)

 

Error message is arcgisscripting.ExecuteError: ERROR 000358: Invalid expression

Outcomes