AnsweredAssumed Answered

Using a Search Cursor to Update Map Text - Not getting all info

Question asked by rralbritton on Jan 20, 2016
Latest reply on Jan 20, 2016 by rralbritton

I've written a python script that reads data from a related table and writes those field values into a text box within ArcMap. The script runs OK when I tell it to print to the command window (all fields are printed), but in the map instead of entering to the new line of text, it appears to be writing over itself. How can I stop this a get it to write in all this info?

import arcpy, os, traceback

mxd = arcpy.mapping.MapDocument(r"\\ad.utah.edu\sys\FM\gis\ags_directories\DDC_Web\Template.mxd")
StopsTable = r"\\csi-files\\fm\\gis\\ags_10_3\\ags_content\\sde_connection_files\\fm-agsDataReader@fm-gisdbtest0.fm.utah.edu.sde\\UUSD.DBO.DDC\\UUSD.DBO.DDC_Stops"

for elm in arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT"):
    
    sc = arcpy.SearchCursor(StopsTable)
    for row in sc:
        if elm.name == "Report":
            print "Stops "+str(row.Stop_Number)+": "+row.Stop_Status+"\n"
            elm.text = "Stops "+str(row.Stop_Number)+": "+row.Stop_Status+"\n"

 

Python Shell Print Screen (to show me the script is doing what I want it to)

 

 

Final MXD after Script runs:

Outcomes