Append with Transformation (Data Loading)

Summary

Appends a source dataset into an existing target dataset with transformation. This tool supports feature class and tabular data as inputs.

Usage

  • Map layers can be used as source data. If a layer has a selection, only the selected records (features or table rows) are used by the Append with Transformation tool.
  • If there are common field names in both the source and target datasets, the tool will automatically match them.
  • The Code Block parameter allows you to create complex expressions. You can enter the code block on the dialog box or as a continuous string in scripting. The expression and code block are connected.
  • The Expression and Code Block parameters only support Python expressions.

Parameters

LabelExplanationData Type
Source Data

The source data to be loaded to the target dataset.

Table View
Target Data

The existing dataset where the source data will be loaded.

Table View
Field Mapping

The target field name and the Python expression being calculated. For multiline Python expressions, use the Code Block parameter.

Value Table
Code Block
(Optional)

The Python code block used to write multiline Python functions. The functions defined here can be referenced in the Field Mapping parameter.

String
Load Data To:
(Optional)

Select whether to load data to the target workspace or to a preview geodatabase.

String
Preview Output Folder
(Optional)

The output folder where a Preview Geodatabase will be created. Data will be loaded to this Preview instead of the Target.

Folder

arcpy.dltsolutions.AppendWithTransformation(source, target, mapping, {code_block}, {load_type}, {preview})
NameExplanationData Type
source

The source data to be loaded to the target dataset.

Table View
target

The existing dataset where the source data will be loaded.

Table View
mapping

The target field name and the Python expression being calculated. For multiline Python expressions, use the Code Block parameter.

Value Table
code_block
(Optional)

The Python code block used to write multiline Python functions. The functions defined here can be referenced in the Field Mapping parameter.

String
load_type
(Optional)

Select whether to load data to the target workspace or to a preview geodatabase.

String
preview
(Optional)

The output folder where a Preview Geodatabase will be created. Data will be loaded to this Preview instead of the Target.

Folder

Code sample

AppendWithTransformation (Python window)

The following Python window script demonstrates how to use the AppendWithTransformation tool in immediate mode:

arcpy.dlt.AppendWithTransformation('D:/data/WaterUtilities.gdb/WaterDistribution/wMain', 'D:/data/Water_AssetPackage.gdb/UtilityNetwork/WaterLine', "material !material!;diameter !diameter!;assetgroup 5")
AppendWithTransformation (stand-alone script)

The following stand-alone script demonstrates how to use the AppendWithTransformation tool:

# Name: AppendWithTransformation.py
# Description: Appends data from source to target with value transformation.

# Import required modules
import arcpy

# Local Variables
source = 'D:/data/WaterUtilities.gdb/WaterDistribution/wMain'
target = 'D:/data/Water_AssetPackage.gdb/UtilityNetwork/WaterLine'
preview = 'D:/data/preview'

code_block = '''
def material_lookup(original: str) -> int:
    """ Convert text descriptions to integers """
    lookup = dict(PVC=1, SP=2, HDPE=3)

    # If the material is not found, return -1
    return lookup.get(original, -1)
'''

# The keys are target fields and the values are the python expression to calculate them.
mapping = {"material": "material_lookup(!MATERIAL!)",
           "diameter": "!DIAMETER!",
           'assetgroup': 5,
           'assettype': 10,
           'installed': '!INSTALL_DATE!'}

arcpy.dlt.AppendWithTransformation(source=source,
                                   target=target,
                                   mapping=list(mapping.items()),
                                   code_block=code_block,
								   load_type='Preview',
								   preview=preview)

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes