Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Alternative to Using 'getValue' with Data Access Module

$
0
0
With the arcpy.da module, we cannot use the getValue method on the row object as we can in arcpy.SearchCursor:

Code:

for row in arcpy.SearchCursor(fc):
            row.getValue("SITE_ID")

We can, however, index over the columns for the row object:

Code:

with arcpy.da.SearchCursor(fc, "*") as cursor:
        for row in cursor:
                print row[1]

I want to use the data access module because it cuts my processing time by almost a half. Indexing over columns on the row object doesn't really work for me because I am using this on an excel spreasheet where users may move columns around. I prefer to pull the heading name as I can with getValue. Is there a way to do this in the da module?

Thanks,
Mike

Viewing all articles
Browse latest Browse all 2485

Trending Articles