I'm valiantly attempting to teach myself Python scripting, and not enjoying this very much so far... All I am trying to do is import a list file (.csv) that corresponds to a field in a shapefile and batch-process some basic GIS functions in a loop. I cannot figure out how to call up the .csv entry in a list for use in an arcpy command. Forgive me if this is a very basic problem, but I've scoured the web for hours trying to figure this out and am getting nowhere fast.
When one is for-looping with arcpy commands, how in the world do you get Python to accept the value in the loop?? Below I can successfully import the .csv list, get one arcpy command (MakeFeatureLayer_management) to go, but then when I want to insert the first value from the .csv list (in the SelectLayerByAttribute_management command) , nothing I try satisfies Python. What am I doing wrong here?!?
arcpy.SelectLayerByAttribute_management("Shedpoints9", "NEW_SELECTION", "GageCode='"+row.insert) #here's where it's breaking. How can I insert the first of the "sheds"?!?
Thanks for turning me on to the csv module. Cool!
# my solution is to construct the where clause here. Note the escaped single quotes.
even if I just cut-and-paste your code.
Well, you didn't want me to test it did you? Put a "print where" in the code right before you do the selection and maybe that will help you figure out what's up. To show all non-printables etc you can try: print repr(where).
Wow... very perceptive guess on what was the problem. Indeed, "GageCode" was an integer. Thanks for helping; perhaps I'm not going about this the right way, but I've taught myself other languages in the past and always gotten along.