Frequently asked question

Why am I getting an error accessing a multivalue parameter in Python at ArcGIS for Desktop 10.1?

Last Published: September 22, 2020

Answer

The data type for a multivalue parameter in a Python script changed in ArcGIS for Desktop 10.1.

In ArcGIS Desktop 10.0, a multivalue parameter (a collection of items) was a ValueTable object. The following is an example of accessing a multivalue table name parameter in ArcGIS Desktop 10.0:

============
import arcpy

tableList = arcpy.GetParameter (0) # a ValueTable object
rowCt = tableList.rowCount
arcpy.AddMessage ("rows: " + str(rowCt))

i = 0
while i < rowCt:
  # Get table name from list
  tbl = tableList.getValue (i, 0)
  arcpy.AddMessage ("table name: " + tbl)
  i += 1
============

In ArcGIS for Desktop 10.1 and later, running the above code returns the following syntax error:

rowCt = tableList.rowCount
  AttributeError: 'list' object has no attribute 'rowCount'

The error occurs because the multivalue parameter is now a list object. An example of the updated code is as follows:

============
import arcpy

tableList = arcpy.GetParameter (0) # a List object
rowCt = len (tableList)
arcpy.AddMessage ("rows: " + str(rowCt))

i = 0
while i < rowCt:
  # Get table name from list
  tbl = tableList[i]
  arcpy.AddMessage ("table name: " + str(tbl))
  i += 1
============

Article ID:000012082

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic