Label | Explanation | Data Type |
Input Table | The input table or feature class. | Table View |
Output Table | The output table or feature class containing the updated fields. | Table |
Output Schema Definition Table
| A table containing the field definitions and calculations that will be used to create the output. | Table View |
Script File (Optional) | A Python file that stores multiple line Python functions to perform calculations for the Output Table parameter fields. | File |
Output Field
Name (Optional) | The field name from the definition table that contains the target field names for the output table. | Field |
Source Field
Name (Optional) | The field name from the definition table that contains the source field names from the input table. | Field |
Output Field
Type (Optional) | The field name from the definition table that defines the data types for the output table. | Field |
Output Field
Decimals or Length (Optional) | The field name from the definition table that defines the number of decimals or the length of the field for the output fields. | Field |
Output Field
Alias (Optional) | The field name from the definition table that defines the alias names for the fields of the output table. | Field |
Output Field
Script (Optional) | The field name from the definition table that defines the calculations for the output fields. | Field |
Summary
Transforms fields in a table or feature class based on schema defined in the definition table and creates a new table or feature class.
You can do the following using this tool:
- Add new fields
- Update existing fields
- Reorder fields
- Change field types
- Change field properties
- Assign or update field aliases
- Calculate field values based on existing fields using Python
- Remove fields
Usage
The input table can be a feature class or a table. The tool outputs a new feature class or table with the updated schema.
The schema changes for the output table are defined by the Output Schema Definition Table parameter.
The following is an example of a definition table:
If the Output Schema Definition Table parameter value includes the following field names, like in the example above. The corresponding parameter values will be populated automatically:
- Target field
- Source field
- Type
- Decimals/Length
- Alias
- Script
The tool calculates new fields using existing fields by providing a script field in the definition table.
An example value in the Script field of the definition table is !TOTPOP!/!AREA!, which calculates the Population Density field. Field names must be enclosed in exclamation points.
The tool can create additional fields that are dependent on other field calculations. For example, the Bev_Index field is calculated using the Bev_Per_Capita field, which is also calculated when the tool is run.
Use the Script File parameter for multiple line Python calculations. To use a script file, create a file with Python functions, and reference the functions in the definition table.
The following is an example of script code for a target field named Bev_Per_Capita:
- A field named Script in the Output Schema Definition Table parameter value with a value of Bev_Per_Capita(!Bev_Total!, !TOTPOP!)
- A Script File parameter value with the following function:
def Bev_Per_Capita(Bev_Total, TOTPOP): return Bev_Total / TOTPOP
The following is an example showing the attribute table before and after running the tool:
Parameters
arcpy.management.BatchUpdateFields(in_table, out_table, field_definition_table, {script_file}, {output_field_name}, {source_field_name}, {output_field_type}, {output_field_decimals_or_length}, {output_field_alias}, {output_field_script})
Name | Explanation | Data Type |
in_table | The input table or feature class. | Table View |
out_table | The output table or feature class containing the updated fields. | Table |
field_definition_table | A table containing the field definitions and calculations that will be used to create the output. | Table View |
script_file (Optional) | A Python file that stores multiple line Python functions to perform calculations for the out_table parameter fields. | File |
output_field_name (Optional) | The field name from the definition table that contains the target field names for the output table. | Field |
source_field_name (Optional) | The field name from the definition table that contains the source field names from the input table. | Field |
output_field_type (Optional) | The field name from the definition table that defines the data types for the output table. | Field |
output_field_decimals_or_length (Optional) | The field name from the definition table that defines the number of decimals or the length of the field for the output fields. | Field |
output_field_alias (Optional) | The field name from the definition table that defines the alias names for the fields of the output table. | Field |
output_field_script (Optional) | The field name from the definition table that defines the calculations for the output fields. | Field |
Code sample
The following Python window script demonstrates how to use the BatchUpdateFields function in a stand-alone script.
arcpy.management.BatchUpdateFields("zip_codes", "MyProject.gdb\zip_codes_BatchUpdateFields", "DATA_TRANSFORMATION.csv", r"C:\BatchUpdate\script.py", "TARGET", "SOURCE", "DATATYPE", "DECIMALS", "ALIAS", "SCRIPT")
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes