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 <SPAN class="operator token">=</SPAN> defaultGDB <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\\CleanTable_'</SPAN> <SPAN class="operator token">+</SPAN> fileName
outLayer <SPAN class="operator token">=</SPAN> <SPAN class="string token">'CleanTable_'</SPAN> <SPAN class="operator token">+</SPAN> fileName <SPAN class="operator token">+</SPAN> <SPAN class="string token">'_View'</SPAN>
defQuery <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Specialty_Code IS NOT NULL"</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>defQuery<SPAN class="punctuation token">)</SPAN>
readyToAppend <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>MakeTableView_management<SPAN class="punctuation token">(</SPAN>allRecords<SPAN class="punctuation token">,</SPAN> outLayer<SPAN class="punctuation token">,</SPAN> defQuery<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
... but this doesn't (line 3)?
allRecords <SPAN class="operator token">=</SPAN> defaultGDB <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\\CleanTable_'</SPAN> <SPAN class="operator token">+</SPAN> fileName
outLayer <SPAN class="operator token">=</SPAN> <SPAN class="string token">'CleanTable_'</SPAN> <SPAN class="operator token">+</SPAN> fileName <SPAN class="operator token">+</SPAN> <SPAN class="string token">'_View'</SPAN>
defQuery <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Specialty_Code IS NOT NULL and Specialty_Code <> \' \'"</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>defQuery<SPAN class="punctuation token">)</SPAN>
readyToAppend <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>MakeTableView_management<SPAN class="punctuation token">(</SPAN>allRecords<SPAN class="punctuation token">,</SPAN> outLayer<SPAN class="punctuation token">,</SPAN> defQuery<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Error message is arcgisscripting.ExecuteError: ERROR 000358: Invalid expression