Overview
This guide explains how to use the Python Operation in eZintegration to efficiently rename multiple columns in a dataset. While the built-in Rename operation is suitable for renaming individual fields, Python enables dynamic and scalable column renaming when working with large datasets.
By using a simple script, users can automatically apply consistent prefixes or naming conventions across multiple columns in a single operation.
When to Use
Use this approach when bulk column renaming is required within an integration pipeline.
- When renaming multiple columns at once
- When applying consistent prefixes or suffixes
- When processing large datasets
- When handling dynamic or changing schemas
- When improving naming standardization
How It Works
The Python Operation accesses the dataset, iterates through each record, and updates column names by adding a predefined prefix.
- Read the dataset from bizdata_dataset_response
- Extract the items array
- Loop through each record
- Prepend a prefix to every column name
- Replace the original dataset with updated values
How to Configure
Python Operation Setup
Add a Python operation to your integration workflow and insert the following script.
Responsedata = []
new_data = pycode_data
prefix = "billTo_"
# Extract items from the dataset response
items = new_data["bizdata_dataset_response"]["items"]
updated_items = []
# Iterate through the items and rename each column by adding the prefix
for item in items:
updated_item = {}
for key, value in item.items():
new_key = f'{prefix}{key}'
updated_item[new_key] = value
updated_items.append(updated_item)
# Update the original dataset with the renamed columns
new_data["bizdata_dataset_response"]["items"] = updated_items
pycode_data = new_data
Key Parameters
The script uses the following configurable parameters.
| Parameter | Description |
|---|---|
| prefix | Defines the prefix added to each column name (e.g., billTo_) |
| items | Dataset array located under bizdata_dataset_response |
Example Use Case
This approach is useful when applying standardized naming conventions across multiple records.
- Prefixing billing-related fields
- Preparing data for ERP or CRM systems
- Normalizing field names for analytics
- Handling schema changes
- Aligning with target system requirements
Troubleshooting
- KeyError: Verify that bizdata_dataset_response and items exist.
- No Columns Renamed: Confirm the prefix value is set.
- Empty Output: Check that items contains records.
- Script Failure: Validate Python syntax.
- Unexpected Fields: Review original dataset structure.
Frequently Asked Questions
Can I use this script to add a suffix instead of a prefix?
Yes. Modify the new_key assignment to append the suffix after the key name.
Does this script overwrite original column names?
Yes. The original keys are replaced with prefixed versions in the output dataset.
Can I rename only selected columns?
Yes. Add conditional logic inside the loop to filter specific keys.
Is this approach scalable?
Yes. It supports large datasets and dynamic schemas.
Do I still need the Rename operation?
The Rename operation is suitable for small, individual changes. Python is recommended for bulk transformations.
Notes
- Always test scripts in preview mode.
- Back up original datasets before transformation.
- Use consistent naming conventions.
<l