POST
|
Ok, someone smarter than I am figured it out. Here is the correct where clause: for dat in datelst: arcpy.SelectLayerByAttribute_management ("hotspots", "NEW_SELECTION", "\"date\" = " + "'" + dat + "'")
... View more
01-06-2011
02:55 PM
|
3
|
0
|
2050
|
POST
|
Thanks for the suggestion. Only the last where clause example 'works' in that it selects records, but similar to everything else I've tried, it selects all records in the dataset (including the dates that were not specified in the where clause).
... View more
01-06-2011
09:21 AM
|
0
|
0
|
3003
|
POST
|
Thanks, but using your code (clm42) it is still selecting all records.
... View more
01-05-2011
09:57 AM
|
0
|
0
|
3003
|
POST
|
The Tool Help suggests that you put the clause in parentheses. I've tried it without the parentheses: arcpy.SelectLayerByAttribute_management ("hotspots", "NEW_SELECTION", "'date' = 'dat'") and I get the same result (all dates selected).
... View more
01-05-2011
08:40 AM
|
1
|
0
|
3003
|
POST
|
Thanks for your reply. When I use the code you suggested arcpy.SelectLayerByAttribute_management ("hotspots", "NEW_SELECTION", ("'date' = '" + dat + "'")) it produces the same result, i.e., the entire dataset is selected, not just the date specified by 'dat'.
... View more
01-05-2011
08:09 AM
|
0
|
0
|
3003
|
POST
|
I am trying to iterate through each date in a shapefile using a list of dates. I am having trouble phrasing my Where clause to select only one date. If I use the following Python code, all dates are selected in each iteration: datelst = ['2002-06-06','2002-06-07','2002-06-08'] arcpy.MakeFeatureLayer_management ("E:/hotspots.shp", "hotspots") for dat in datelst: arcpy.SelectLayerByAttribute_management ("hotspots", "NEW_SELECTION", ("'date' = 'dat'")) I have tried rephrasing the Where clause in many different ways, but the result is that all records are selected, no records are selected, or an error message is returned. The query is successful if I use the string itself (e.g. arcpy.SelectLayerByAttribute_management ("hotspots", "NEW_SELECTION", "date = '2002-06-06'") but then it is not possible to iterate through all of the dates in the file.
... View more
01-04-2011
03:01 PM
|
0
|
15
|
18893
|
Title | Kudos | Posted |
---|---|---|
1 | 01-05-2011 08:40 AM | |
3 | 01-06-2011 02:55 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|