Row

Synthèse

The Row object represents the row of a table. The Row object is returned from InsertCursor, SearchCursor, and UpdateCursor.

Héritage :

The cursor functions and Row object only remain for use in legacy scripts. When authoring or updating scripts, it is recommended that you use the cursors in the arcpy.da module. The arcpy.da cursors provide improved performance and functionality, and support for newer field types and tokens.

Discussion

The Row object dynamically support field names from the data source as read/write properties. Field names that cannot be supported directly as a property, such as qualified field names that include periods, can be accessed using the setValue and getValue methods.

Vue d’ensemble des méthodes

MéthodeExplication
getValue (field_name)

Returns the field value.

isNull (field_name)

Is the field value null.

setNull (field_name)

Sets the field value to null.

setValue (field_name, object)

Sets the field value.

Méthodes

getValue (field_name)
ParamètreExplicationType de données
field_name

The field from which the value will be accessed.

String
Valeur renvoyée
Type de donnéesExplication
Object

The field value.

isNull (field_name)
ParamètreExplicationType de données
field_name

The field to be queried.

None
Valeur renvoyée
Type de donnéesExplication
Boolean

True if the field value is null.

setNull (field_name)
ParamètreExplicationType de données
field_name

The field that will be set to null.

String
setValue (field_name, object)
ParamètreExplicationType de données
field_name

The field that will be set to the new value.

String
object

The value used to set the field value.

Object

Exemple de code

Row example

Use update cursor to fetch row from feature class, update field value and row, iterating through rows in cursor.

import arcpy

# Set the workspace
arcpy.env.workspace = "c:/data"

# Use row object to get and set field values
cursor = arcpy.UpdateCursor("Addresses.dbf", '"STATENAME" = \'Ariz\'' )

# Iterate through rows and update values
for row in cursor:
    row.setValue("STATENAME", "Arizona")
    cursor.updateRow(row)

del cursor, row

Rubriques connexes