POST
|
Thanks a lot Joshua Chisholm for your help. it worked.
... View more
01-31-2014
05:49 AM
|
0
|
0
|
507
|
POST
|
Hello Shakir, The where statement is the problem. Can you explain exactly what you are trying to achieve with the where statement. Here are a few things to note: 1) A SQL (where) must be passed as a string (text) in python. This means it has to have quotes around it. You may also need to add some Backslashs (\) to quote marks. This tells python to use them only as a character and not defining the start/end of a string. 2) When building a SQL statement with wildcards ('%') you must use the 'LIKE' condition, not the '=' condition. Try this out:
my_feature = r"C:\Path\To\File.shp"
where = '\"Name\" LIKE \'%s\'' #produces this: "Name" LIKE '%s'
cursor2 = arcpy.UpdateCursor(my_feature,where)
Let me know how it goes. Good Luck! ~Josh Thanks for your reply but got following error
my_name = "New Horizon's place.JPG"
my_feature = r"C:\Path\To\File.shp"
#where = '\"Name\" LIKE \'%s\'' #produces this: "Name" LIKE '%s'
where = '\"Name\" LIKE \'%s\'' %my_name # here the my_name is the search string
cursor2 = arcpy.UpdateCursor(my_feature,where)
Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\__init__.py", line 1165, in UpdateCursor return gp.updateCursor(dataset, where_clause, spatial_reference, fields, sort_fields) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 364, in updateCursor self._gp.UpdateCursor(*gp_fixargs(args, True))) RuntimeError: ERROR 999999: Error executing function. An invalid SQL statement was used. An invalid SQL statement was used. [my_feature] An invalid SQL statement was used. [SELECT * FROM my_feature WHERE ( "Name" LIKE 'New Horizon's place.JPG' )]
... View more
01-31-2014
04:52 AM
|
0
|
0
|
507
|
POST
|
Hi I am trying to update a field from File geodatabase using update cursor using where clause. but the search string has quote. I tried all different way to use where clause but did not work. I really apprecaite if anyone can help me to solve this problem or work around. Thanks =============================== Here is the code that I am using from python win. =============================== >>>my_name = "New Horizon's place.JPG" >>> where = Name = '"%s"' %my_name >>> cursor2 = arcpy.UpdateCursor(my_feature,where) Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\__init__.py", line 1165, in UpdateCursor return gp.updateCursor(dataset, where_clause, spatial_reference, fields, sort_fields) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 364, in updateCursor self._gp.UpdateCursor(*gp_fixargs(args, True))) RuntimeError: ERROR 999999: Error executing function. An invalid SQL statement was used. An invalid SQL statement was used. [my_feature] An invalid SQL statement was used. [SELECT * FROM my_feature WHERE ( "New Horizon's place.JPG" )]
... View more
01-31-2014
03:40 AM
|
0
|
4
|
1416
|
POST
|
HI, I am trying to find only valid layer files (.lyr) from the list of all layer files under a folder. (If the .lyr file is valid, I only need to retreive those names only. If there is no Feature Class or shape file is assoicate with the layer files I dont need to retrieve. I would like to use Geoprocessing tool to do so.) Any help or idea is highly apprecaited. Thanks Shakir
... View more
10-25-2010
07:52 AM
|
0
|
0
|
654
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|