Select to view content in your preferred language

working with string variables in a FeaturClass

2033
2
08-12-2010 08:08 PM
Jose_LuisGarcinuno-Oporto
Occasional Contributor
I am trying to create a variable to be used in the select statement. So far, this is the code that I have right now.
rows1 = gp.SearchCursor(a + "copySelect1")
        row1 = rows1.Next()
        while row1 <> None:
           road = row1.Getvalue("ROADNAME")
           print road

           # Process: Select...the next line of code works, so the challenge is How to incorporate road variable here, to replace 'RD-300', it is in square brakets because it is a FeaturClass in a GeoDataset, I know how to works with shapefiles but this is not the case.
           gp.Select_analysis(a + "copySelect1", "Rclip" + a + "Select", "[ROADNAME] = 'RD-300'")

           gp.Select_analysis(a + "copySelect1", "Rclip" + a + "Select", "'[ROADNAME] = + str(road)), my problems are the double quotes, road variable is a string variable, what happen if it is integer?
Thanks in advance
0 Kudos
2 Replies
ChrisMathers
Deactivated User
You dont want to make the change directly in the tool inputs. Make the string before and just drop it in as a variable.


query="[ROADNAME] = '"+road+"'"
gp.Select_analysis(a + "copySelect1", "Rclip" + a + "Select", query)
0 Kudos
Jose_LuisGarcinuno-Oporto
Occasional Contributor
Thanks a lot Chris, its work perfectly, I really appreciate your time.
0 Kudos