Summary
Appends a source dataset into an existing target dataset with transformation. This tool supports feature class and tabular data as inputs.
Syntax
arcpy.NOALIAS.AppendWithTransformation(source, target, mapping, {code_block}, {load_type}, {preview})
Name | Explanation | Data Type |
source | The source data to be loaded to the target dataset. | Table View |
Source Data
| 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 |
Target Data
| 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 |
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 |
Code Block
| 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 |
Load Data To:
| 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 |
Preview Output Folder | The output folder where a Preview Geodatabase will be created. Data will be loaded to this Preview instead of the Target. | Folder |
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)
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes