21 reputation
13
bio website
location
age
visits member for 1 year, 11 months
seen Dec 2 '12 at 20:27

Nov
26
awarded  Notable Question
Apr
19
awarded  Popular Question
Oct
9
awarded  Commentator
Oct
9
comment Python script for constructing a WHERE clause from user input
@ R.K. - sorry. had to leave for job #2 after I posted. To answer your question, "123" = 'ABC' OR 'DEF' "which is it?' = both. If the ultimate goal is to select attributes ABC and DEF from field 123 then the correct SQL statement form for ArcGIS should read "123" = 'ABC' OR "123" = 'DEF'. This would select out both ABC and DEF
Oct
8
comment Python script for constructing a WHERE clause from user input
@ R.K. - it now runs without an error but basically gives me back the same situation as my original post : "\CO_NAME\" = '123:456'
Oct
8
comment Python script for constructing a WHERE clause from user input
thank you for working on this, unfortunately, it doesn't work. I get the following error message: Traceback (most recent call last): File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.‌​py", line 326, in RunScript exec codeObject in main.__dict__ File "C:\GIS540_Project\sql_RKedits.py", line 44, in <module> SQL=whereClause(InputFC,Field,Values) File "C:\GIS540_Project\sql_RKedits.py", line 25, in whereClause if whereClause == "": UnboundLocalError: local variable 'whereClause' referenced before assignment
Oct
8
comment Python script for constructing a WHERE clause from user input
@R.K. yes, according to formatting rules in ArcGIS 10.0 the field from which the attributes are being selected needs to follow this format. As far as supplying test dat, I'm new to this forum - how do i do that?
Oct
8
comment Python script for constructing a WHERE clause from user input
@sgrieve if I try and run the current script through the select by attribute tool the error message reads: "ExecuteError: ERROR 000210: Cannot create output CountyBoundary_Select.shp" This makes sense since the format of the SQL statement is incorrect (as noted in my orginal post)
Oct
8
asked Python script for constructing a WHERE clause from user input
Oct
8
comment Python Script for Select by Attributes taking user input
I figured out that the reason its returning an empty shapefile is the query statement is splitting county names into individual letters. For example if I enter "ABC" as a county the where clause reads it as 'A' 'B' 'C', and it only does this for the first county in the string. I'm still working on how to fix this
Oct
6
comment Python Script for Select by Attributes taking user input
The last script you provided runs but returns an empty shapefile. I'm not sure what this means. I posted an answer below that also runs an returns the first county in a list.
Oct
6
answered Python Script for Select by Attributes taking user input
Oct
6
awarded  Student
Oct
6
comment How to Extract by Attribute Using ModelBuilder with User Input?
@blah238 - At the beginning of your answer you state that this model would run better as a python script. I'm trying write a script that performs the exact task that you have laid out here in model builder. I'm stuck because I don't understand how to take user derived input (the multi values which may be one or more) and write a SQL expression for this. Thanks.
Oct
6
comment Python Script for Select by Attributes taking user input
thank you for your input. Maybe I'm not asking this question correctly so please bare with me. I have a countys shapefile that contains a "CO_NAME" field. From this field I want a user to select one or more counties. These selected counties need to become part of the SQL expression. Since the name of the counties will be user derived how is the SQL expression constructed?
Oct
5
comment Python Script for Select by Attributes taking user input
I'm not exactly sure how to construct the where clause and the how to pass this clause through a SQL statement for the select by attribute tool. This post: gis.stackexchange.com/questions/21760/… is almost exactly what I need except I need it to work as a python script
Oct
5
asked Python Script for Select by Attributes taking user input