Select to view content in your preferred language

reading a user text file to zoom to a particular area

1623
10
03-08-2011 11:59 AM
MikePowell
Deactivated User
I am having a hard time trying to figure out this. I have a .txt file with township/range/sections that I need to read and than zoom to the section, refresh the map and export files from it and than go to the next one. Here is the code:

import arcpy

mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\bookmaps.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]
lyr = arcpy.mapping.ListLayers(mxd, "GCDB*", df)[0]
data_file = open('todo.txt', 'r')
for item in data_file:
    print item
    rows = arcpy.SearchCursor(lyr)
    row = rows.next()
    while row:
        trs = row.getValue("TOWN")
        if trs == item:
            print "Township Range Section is "+trs
        row = rows.next()
   
    del rows

I know it reads the list (with the first print) but it only gets to the next print for the last item in the list. No matter how many are in the list it only seems to do the last item. What am I not seeing?
Tags (2)
0 Kudos
10 Replies
TerrySilveus
Frequent Contributor
Sorry for the indenting thing. I guess I didn't quite understand the use of Code(). I think you still can understand it. Thanks again

I should mention that I am running this in PythonWIN. I prefer that over running it in ArcMap.


I had the same problem posting code when I started using the forum.  If you put
 code goes in between these two wrappers 
start your code with "CODE" in brackets and end with "/CODE" in brackets
0 Kudos