ExtendTable
Summary
The ExtendTable function joins the contents of a NumPy structured array to a table based on a common attribute field. The input table is updated to contain the fields from the join table.
Discussion
The records in the in_array field are matched to the records in the in_table field. A match is made when the table_match_field and array_match_table values are equal. The join is permanent.
NumPy is a fundamental package for scientific computing in Python, including support for a powerful N-dimensional array object. For more information, see NumPy in ArcGIS.
Syntax
ExtendTable(in_table, table_match_field, in_array, array_match_field, {append_only})
| Parameter | Explanation | Data Type |
|---|---|---|
|
in_table |
The target table to which fields from a NumPy array will be appended. |
String |
|
table_match_field |
A field name from |
String |
|
in_array |
A NumPy structured array to be appended to Matching |
NumPyArray |
|
array_match_field |
A field name from |
String |
|
append_only |
Controls how fields are added or updated in the existing table. If True, fields will be appended to the existing table only. If any of the NumPy field names exist already in the If False, existing fields will be updated if they share a common field name with fields in the NumPy array. Any matching fields must have a compatible field type. For example, a NumPy string field cannot be appended into a numeric field. The default value is True. |
Boolean |
Code sample
Use the ExtendTable function to join a NumPy array to an existing table.
import arcpy
import numpy
# numpy array
array = numpy.array(
[(1, "a", 1111.0), (2, "b", 2222.22)],
numpy.dtype(
[("idfield", numpy.int32), ("textfield", "|S256"), ("doublefield", "<f8")]
),
)
# Append the array to an existing table
arcpy.da.ExtendTable("c:/data/base.gdb/current_table", "tableid", array, "idfield")