Select to view content in your preferred language

Python get two values in a Search Cursor than go to next line

5183
12
Jump to solution
06-18-2015 07:22 AM
deleted-user-MS0lE1F_0-sy
Deactivated User

I am trying to write my getValues to a text element loop, but I want there to be two results per line before going to the new line.  I am having trouble figuring it out? I think I might new a while loop perhaps instead of a for loop, and probably need to use next() somewhere?  But that seems to just loop through each name and put one result instead of all four. 

I don't want this:   Anna                              I want this:   Anna  Ben

                             Ben                                                    Charlie Dora

                             Charlie

                             Dora

I don't know what to use in here to achive this.

rows = arcpy.SearchCursor(Layer)
        textValue = ""
        for row in rows:
            textValue += row.getValue(Value1) + '\r\n'
        ParcelText2.text = textValue
        del rows
0 Kudos
12 Replies
TomSellsted
MVP Alum

You are welcome!

0 Kudos
IanMurray
Honored Contributor

Yes, your was set-up for a true first response, while mine was set-up for a false. 

Either way, he got what he needed, thanks for the input.

IanMurray
Honored Contributor

Matthew,

I wanted to recommend for future using of cursors that you use the new data access cursors(arcpy.da.SearchCursor  e.g.).  They are significantly faster than the old style cursors you were using in your code.  The parameters and syntax are somewhat different from the cursors you were using, but still easy to use.

Here is the link for the new cursors versus old cursors.

ArcGIS Help (10.2, 10.2.1, and 10.2.2)