Overview
Splitting strings using structured patterns is a common requirement in data enrichment and integration workflows. This process enables users to extract specific values from composite fields and store them as separate keys.
In eZintegrations, Python Operations can be used to split the org field into Autonomous System Number (ASN) and Organization Name (AS) values.
When to Use
Use this method when organizational or network information is stored in a single field and needs to be separated for analysis or processing.
- Extracting ASN and organization names
- Normalizing network metadata
- Enriching IP intelligence data
- Improving reporting and classification
- Structuring unformatted text fields
How It Works
The Python script retrieves the value of the org key and splits it into two parts using the split() function.
The first part represents the ASN value, and the second part represents the organization name. These values are then added as new keys in the output JSON.
Incoming Data
The Python Operation receives IP and organization details in JSON format.
{
"ip": "xx.249.74.xxx",
"hostname": "crawl-xx.249.74.xxx.googlebot.com",
"city": "Tulsa",
"region": "Oklahoma",
"country": "US",
"loc": "36.1540,-95.9928",
"org": "AS15169 Google LLC",
"postal": "74102",
"timezone": "America/Chicago"
}
Python Operation Logic
The following Python script extracts the org value, splits it into ASN and AS components, and prepares the enriched output.
# Sending to input of operation
Responsedata = []
# Extract the value of the "org" key
org_value = pycode_data.get("org", "") # Default to an empty string if "org" is missing
# Split the "org" value into ASN and AS
asn_part, as_part = org_value.split(" ", 1)
# Prepare the response
response = {
"asn": asn_part, # ASN value (e.g., AS15169)
"as": as_part # AS value (e.g., Google LLC)
}
# Sending to output of operation
pycode_data.update(response)
Outgoing Data
After processing, the Python Operation appends two new keys, asn and as, to the original dataset.
{
"ip": "xx.249.74.xxx",
"hostname": "crawl-xx.249.74.xxx.googlebot.com",
"city": "Tulsa",
"region": "Oklahoma",
"country": "US",
"loc": "36.1540,-95.9928",
"org": "AS15169 Google LLC",
"asn": "AS15169",
"as": "Google LLC",
"postal": "74102",
"timezone": "America/Chicago"
}
How to Use
Follow these steps to split the organization string and enrich your data.
- Configure the integration to receive IP and organization data.
- Open the Python Operation editor.
- Insert the string-splitting script.
- Ensure the input contains the org field.
- Save and deploy the workflow.
- Test the operation with sample input.
Use Case Example
This approach helps classify network traffic and associate IP addresses with service providers.
- Input: AS15169 Google LLC
- Extracted ASN: AS15169
- Extracted AS: Google LLC
- Usage: Network monitoring and analytics
Troubleshooting
- Verify that the org field is present in the input.
- Ensure the value contains a space separating ASN and organization name.
- Check for empty or null values.
- Review logs if splitting fails.
- Confirm that pycode_data is properly initialized.
Frequently Asked Questions
What does the split(” “, 1) function do?
It splits the string at the first space, returning two parts: the ASN and the organization name.
What happens if the org field is missing?
The script assigns an empty string, which prevents runtime errors but may cause splitting to fail.
Can this script handle multiple spaces?
Yes. Only the first space is used as the split point, and the remaining text is preserved.
Is this a regular expression-based split?
No. This implementation uses Python’s standard split() method with a delimiter, not a regex pattern.
Can I modify this to use regular expressions?
Yes. The logic can be extended using Python’s re module if advanced pattern matching is required.
Notes
- This method assumes a consistent org field format.
- Additional validation may be required for unstructured inputs.
- Use standardized field names for downstream compatibility.
- Review extracted values before using them in business logic.