Error:  TypeError: sequence size must match size of the row

相关信息
Article ID: 40604
Software:
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
ArcGIS for Desktop Basic 10.1
Platforms:
Windows XP, Server 2003, Vista, Server 2008, Windows 7, Windows 8, Server 2012

错误信息
When adding rows to a feature class or table using the InsertCursor ArcPy function, the following error is returned:

"TypeError: sequence size must match size of the row."

错误原因
The cause for this error is usually either related to field matching or syntax errors.


1. Field matching error
When setting up the values to be inserted into the feature class or table, the fields must match the defined fields within the cursor. This includes setting them in the correct order and ensuring that the field types and lengths match the data to be inserted.

In this example, the row values being inserted do not match up correctly with the InsertCursor fields:

2. Python syntax error
There are many possible syntax errors, but this error usually relates to the way the data list is set up.

In this example, the XY coordinates are in a tuple that is not formatted correctly within the list to create the geometry:
已邀请:

EsriSupport

赞同来自:

解决方案
Check to ensure that the row values being inserted line up with the InsertCursor fields, and the geometry lists are properly formatted.


1. Solution to field matching error 
Set only the necessary fields required for the data being inserted. 


2. Solution to syntax error 
When using the SHAPE@xy token to create a single point, a tuple with a single value is required. To be properly recognized, a single value tuple should be written with a trailing comma. 

-OR- 
Breaking out SHAPE@X and SHAPE@Y allows a tuple with a single value to be avoided. 

【相关参考】
InsertCursor (arcpy.da)
Data Structures > Tuples and Sequences
创建及修改时间
Created: 10/10/2012

Last Modified: 8/6/2013
原文链接
http://support.esri.com/en/kno ... 40604

要回复问题请先登录注册