Table To Domain (Data Management)

Summary

Creates or updates a coded value domain with values from a table.

Usage

  • A domain can also be created with the Create Domain tool.

  • The standard delimiter for tabular text files with extensions .csv or .txt is a comma, and for files with a .tab extension, a tab. To use an input table with a nonstandard delimiter, you must first specify the correct delimiter used in the table using a schema.ini file.

Parameters

LabelExplanationData Type
Input Table

The database table from which the domain values will be derived.

Table View
Code Field

The field in the database table from which the domain code values will be derived.

Field
Description Field

The field in the database table from which the domain description values will be derived.

Field
Input Workspace

The workspace that contains the domain that will be created or updated.

Workspace
Domain Name

The name of the domain that will be created or updated.

String
Domain Description
(Optional)

The description of the domain that will be created or updated. Domain descriptions of existing domains are not updated.

String
Update Option
(Optional)

Specifies how the domain will be updated when you're using an existing domain.

  • Append the valuesThe values from the input table will be appended to the existing domain values. This is the default.
  • Replace the valuesThe existing domain values will be replaced with the values from the input table.
String

Derived Output

LabelExplanationData Type
Updated Input Workspace

The updated input workspace.

Workspace

arcpy.management.TableToDomain(in_table, code_field, description_field, in_workspace, domain_name, {domain_description}, {update_option})
NameExplanationData Type
in_table

The database table from which the domain values will be derived.

Table View
code_field

The field in the database table from which the domain code values will be derived.

Field
description_field

The field in the database table from which the domain description values will be derived.

Field
in_workspace

The workspace that contains the domain that will be created or updated.

Workspace
domain_name

The name of the domain that will be created or updated.

String
domain_description
(Optional)

The description of the domain that will be created or updated. Domain descriptions of existing domains are not updated.

String
update_option
(Optional)

Specifies how the domain will be updated when you're using an existing domain.

  • APPENDThe values from the input table will be appended to the existing domain values. This is the default.
  • REPLACEThe existing domain values will be replaced with the values from the input table.
String

Derived Output

NameExplanationData Type
out_workspace

The updated input workspace.

Workspace

Code sample

TableToDomain example 1 (Python window)

The following Python window script demonstrates how to use the TableToDomain function in immediate mode.

import arcpy
from arcpy import env
env.workspace =  "C:/data"
arcpy.TableToDomain_management ("diameter.dbf",
                                "code",
                                "descript",
                                "montgomery.gdb",
                                "diameters",
                                "Valid pipe diameters")
TableToDomain example 2 (stand-alone script)

This stand-alone script uses the TableToDomain function as part of a workflow.

# Name: TableToDomain.py
# Description: Update an attribute domain to constrain valid pipe material values

# Import system modules
import arcpy
 
# Set the workspace (to avoid having to type in the full path to the data every time)
arcpy.env.workspace = "C:/data"

#Set local parameters
domTable = "diameter.dbf"
codeField = "code"
descField = "descript"
dWorkspace = "Montgomery.gdb"
domName = "diameters"
domDesc = "Valid pipe diameters"

# Process: Create a domain from an existing table
arcpy.TableToDomain_management(domTable, codeField, descField, dWorkspace, domName, domDesc)

Related topics