my_name = "New Horizon's place.JPG" my_name = my_name.replace("\'","\'\'") my_feature = r"C:\Path\To\File.shp" where = '\"Name\" LIKE \'%s\'' %my_name # here the my_name is the search string cursor2 = arcpy.UpdateCursor(my_feature,where)
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
my_feature = r"C:\Path\To\File.shp" where = '\"Name\" LIKE \'%s\'' #produces this: "Name" LIKE '%s' cursor2 = arcpy.UpdateCursor(my_feature,where)
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)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.