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. 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).
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 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.
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.
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 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 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
Features with attributes to be split.
Output Ports
Features with the selected attribute value split into a list attribute.
Parameters
Attribute to Split | After you connect this transformer to an input feature stream, choose an attribute from the pull-down menu. |
Delimiter or Format String |
If Delimiter: enter the character used as a delimiter. Special characters may be entered using the Text Editor from the drop-down menu. If Format String (fixed-width): provide a string in the format #s#s#s, where each number is the length of the substring you wish to extract. |
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
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
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. There are a number of tools and shortcuts that can assist in constructing values, generally available from the drop-down context menu adjacent to the value field.
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 - whether entered directly in a parameter or constructed using one of the editors.
These functions manipulate and format strings. | |
A set of control characters is available in the Text Editor. | |
Math functions are available in both editors. | |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Working with User Parameters | Create your own editable parameters. |
Reference
Processing Behavior |
|
Feature Holding |
No |
Dependencies | None |
FME Licensing Level | FME Base Edition and above |
Aliases | |
History | |
Categories |
FME Knowledge Center
The FME Knowledge Center is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for all results about the AttributeSplitter on the FME Knowledge Center.
Examples may contain information licensed under the Open Government Licence – Vancouver