Skip to main content

Row

Resumen

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

Debate

Heredado:

The Row object is superseded by the cursors in the arcpy.da module and only remains for use in legacy scripts.

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.

Métodos

getValue(field_name)

Returns the field value.

Nombre Explicación Tipo de datos

field_name

The field from which the value will be accessed.

String

Valor de retorno

Tipo de datos Explicación

Object

The field value.

isNull(field_name)

Specifies whether the field value is null.

Nombre Explicación Tipo de datos

field_name

The field that will be queried.

None

Valor de retorno

Tipo de datos Explicación

Boolean

True if the field value is null.

setNull(field_name)

Sets the field value to null.

Nombre Explicación Tipo de datos

field_name

The field that will be set to null.

String

setValue(field_name, object)

Sets the field value.

Nombre Explicación Tipo de datos

field_name

The field that will be set to the new value.

String

object

The value that will be used to set the field value.

Object

Muestra de código

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