FME Transformers: 2024.2
FME Transformers: 2024.2
AttributeSplitter
Splits attribute values into parts, based on a delimiter or fixed-width pattern, and creates a list attribute containing one list element for each part.
Typical Uses
- Converting a delimited list of values into an FME list attribute
- Extracting one part of an attribute value based on column-aligned text with a known structure
How does it work?
Once connected to an input feature stream, the AttributeSplitter lets you select an Attribute to Split. The value for that attribute is divided into parts based on parameter selections, and the results added to a new list attribute.
Splitting can be done with either a delimiter (such a comma-separated list of values), or by providing a format string that identifies the width of each part in a piece of column-aligned text.
In the case of a delimited list, the number of parts in the value can be variable. A field qualifying character may also be specified for cases where the delimiter appears within the string as a non-delimiting value (such as commas within addresses in comma-separated strings).
For fixed-width splitting, parts will be extracted exactly according to the format string provided.
Whitespace may be trimmed from the resulting values, and Empty Parts - parts with no resulting value - may be kept or dropped.
The new list attributes can be used with other list-based transformers. Alternatively, you can expose specific list elements to be used as individual attributes (see example below).
Examples
Example: Splitting an attribute with a variable number of parts (delimiter)
In this example, we have a dataset of food trees. For each location, there may be any number of individual trees, and the names of the varieties are stored in the FOOD_TREE_VARIETIES attribute. The names of the varieties are separated by semicolons - “;”.
We will split this attribute into a list attribute for further processing in the workspace.
The Food Trees dataset is routed into an AttributeSplitter, where the new list attribute - Varieties{} - will be created.
In the parameters dialog, we select the name of the attribute and define how the split should be done. Delimiter or Format String is set to ; (semicolon), any whitespace will be trimmed, any empty parts will be dropped, and the new list attribute is named Varieties.
Viewing the results in the FME Data Inspector, the FOOD_TREE_VARIETIES attribute has been split into its component parts, and the parts have been added as individual elements to the new list attribute.
Example: Splitting delimited addresses into attributes (exposing individual list elements)
In this example, we have a shapefile containing points of interest, with postal addresses included as a single attribute. The parts of the addresses are separated by commas.
Unlike the first example (with a variable number of tree types), we do know how many parts these attributes should have.
In the parameters dialog, the Delimiter is set to comma (,), we will trim whitespace, and create a new list attribute called Address. Note that Drop Empty Parts is set to No - if part of an address is missing, dropping it would cause the other parts to end up in the wrong list element.
With the AttributeSplitter configured, the Address{} list is now available in the transformer output. Right-click (context menu) on the list name, and we can Expose Elements from the list.
List elements are numbered starting with zero (0). In the Select List Elements dialog, entering the range 0-3 will expose the four total list elements that make up the address.
With the list elements exposed and now accessible, an AttributeManager is used to rename them according to their content.
The output features now have individual address component attributes.
Example: Splitting attributes with fixed-width component parts (format string)
In this example, we have a dataset of crime incidents. The DATETIME attribute contains a string composed of date and time information, which we want to split into its component parts.
The features are routed into an AttributeSplitter. In the parameters dialog, we use a Format String to split the attribute at defined character positions. The Format String uses a #s#s#s format - integers defining the width of each part, separated by an “s” character.
After exposing all of the list elements, an AttributeManager renames them, and they are available as attributes.
Usage Notes
- Lists are usually indicated in FME Workbench by name, followed by a pair of curly brackets - mylist{}.
A specific list element contains its number between the brackets - mylist{0} - To access specific list elements in FME Workbench, right-click on a list name in the attribute list and choose Expose Elements.
- For information on working with lists, see List Attributes.
- To split attributes using regular expression pattern matching, consider using the StringSearcher.
Configuration
Input Ports
Input
Features with attributes to be split.
Output Ports
Output
Features with the selected attribute value split into a list attribute.
Parameters
General
Attribute to Split |
After the transformer is connected to an input feature stream, choose an attribute from the pull-down menu. |
Delimiter or Format String |
Provide a string to be used for splitting, in the format of your choice:
|
Field Qualifier Character |
When using a delimiter, if a value is provided here, delimiters between pairs of the specified Field Qualifier Character will be treated as ordinary strings and not delimiting characters (also known as escaping). Consider this comma-delimited record: FA035,2009,City Hall Lawn Garden,"453 W 12th Av, Vancouver BC",Yes If Field Qualifier Character is set to ", the address will be extracted as an intact string which includes a comma: "453 W 12th Av, Vancouver BC" Without it, the address would be split at the comma. Note that the Field Qualifier Character is not removed from the string. |
Trim Whitespace |
By default, the resulting strings have both leading and trailing (left and right) whitespace removed but you can change the setting to either left or right, or none. |
List Name |
Enter a name for the new list attribute. |
Drop Empty Parts |
Determines whether to keep empty parts that resulted from splitting. By default, all parts will be returned, whether or not they are empty. If the parameter value is set to Yes, only non-empty parts will be returned. If this parameter is set to No, splitting a,b,,,c,d,e with commas returns the following list: `_list{0}' has value `a' `_list{1}' has value `b' `_list{2}' has value `' `_list{3}' has value `' `_list{4}' has value `c' `_list{5}' has value `d' `_list{6}' has value `e' If this parameter is set to Yes, splitting a,b,,,c,d,e with commas returns the following list: `_list{0}' has value `a' `_list{1}' has value `b' `_list{2}' has value `c' `_list{3}' has value `d' `_list{4}' has value `e' |
Editing Transformer Parameters
Transformer parameters can be set by directly entering values, using expressions, or referencing other elements in the workspace such as attribute values or user parameters. Various editors and context menus are available to assist. To see what is available, click beside the applicable parameter.
How to Set Parameter Values
Defining Values
There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters.
Using the Text Editor
The Text Editor provides a convenient way to construct text strings (including regular expressions) from various data sources, such as attributes, parameters, and constants, where the result is used directly inside a parameter.
Using the Arithmetic Editor
The Arithmetic Editor provides a convenient way to construct math expressions from various data sources, such as attributes, parameters, and feature functions, where the result is used directly inside a parameter.
Conditional Values
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Content
Expressions and strings can include a number of functions, characters, parameters, and more.
When setting values - whether entered directly in a parameter or constructed using one of the editors - strings and expressions containing String, Math, Date/Time or FME Feature Functions will have those functions evaluated. Therefore, the names of these functions (in the form @<function_name>) should not be used as literal string values.
Content Types
These functions manipulate and format strings. | |
Special Characters |
A set of control characters is available in the Text Editor. |
Math functions are available in both editors. | |
Date/Time Functions | Date and time functions are available in the Text Editor. |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Creating and Modifying User Parameters | Create your own editable parameters. |
Dialog Options - Tables
Table Tools
Transformers with table-style parameters have additional tools for populating and manipulating values.
Row Reordering
|
Enabled once you have clicked on a row item. Choices include:
|
Cut, Copy, and Paste
|
Enabled once you have clicked on a row item. Choices include:
Cut, copy, and paste may be used within a transformer, or between transformers. |
Filter
|
Start typing a string, and the matrix will only display rows matching those characters. Searches all columns. This only affects the display of attributes within the transformer - it does not alter which attributes are output. |
Import
|
Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers. |
Reset/Refresh
|
Generally resets the table to its initial state, and may provide additional options to remove invalid entries. Behavior varies between transformers. |
Note: Not all tools are available in all transformers.
For more information, see Transformer Parameter Menu Options.
Reference
Processing Behavior |
|
Feature Holding |
No |
Dependencies | None |
Aliases | |
History |
FME Community
The FME Community has a wealth of FME knowledge with over 20,000 active members worldwide. Get help with FME, share knowledge, and connect with users globally.
Search for all results about the AttributeSplitter on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver, Open Government Licence - British Columbia, and/or Open Government Licence – Canada.