AttributeSplitter
Splits a selected attribute into a list attribute. Each item in the list will contain a single token split from the list.
You would use this transformer, for example, to separate an attribute that has a comma-separated value list into its component pieces.
Input Ports
The feature type that contains the attribute you want to split.
Output Ports
Features with the selected attribute value split into a list attribute.
Parameters
After you connect this transformer, choose an attribute from the pull-down menu.
Characters can be expressed as regular characters but they can also include any number of control characters.
Special character sequences (Advanced Editor only) are interpreted as shown below:
Sequence | Description |
---|---|
Ctrl+Shift+h (^H) |
Backspace (0x08) |
Ctrl+Shift+l (^L) |
Form feed (0x0c) |
Ctrl+Shift+j (^J) |
Newline (0x0a) |
Ctrl+Shift+r (^M) |
Carriage return (0x0d) |
Ctrl+Shift+i (^I) |
Tab (0x09) |
Ctrl+Shift+k (^K) |
Vertical tab (0x0b) |
Alternatively, instead of using a delimiter character you can provide a string in the format #s#s#s, where each number is the length of the substring you wish to extract.
Defining Special Characters
You can define special characters through the Basic or Advanced Editors. Click Open Editor from the parameter menu:
Basic Text Editor
Select Constant from the String Type column (or, in some transformers, the Value column) and click on the empty field in the column:
Click the browse button to the right of the column to open an Edit Value dialog. In this editor, enter characters using the shortcut keys from the table above.
Advanced Text Editor
Enter characters using the shortcuts from the table above.
Note: To see tab characters, click the Options menu on the bottom left and select Show Spaces/Tabs.
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.
The default list name is _list, but you can change it to a name that is more specific to your workflow.
Note: When a feature has an existing list attribute of the same name as List Name, FME overwrites the newly-created elements onto the existing list attribute. For example, consider a feature that has an attribute src with values 1,2, and a list attribute _list with values {A,B,C,D}. If the AttributeSplitter splits src into a list attribute that is also named _list, the result is one list attribute _list with values {1,2,C,D}.
Determines whether to keep empty parts (or tokens) 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'
Usage Notes: Accessing Individual List Elements
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}
Attributes of a list element are shown like this:
mylist{0}.myattribute
However, list elements generated by the AttributeSplitter contain values but no attributes.
To access specific list elements in Workbench, right-click on a list name in the attribute list and choose Expose Elements.
In the dialog that appears, type the number of elements you want to expose.
Keep in mind that list elements start counting at 0, so exposing 1 element of mylist{} will result in the extra attribute mylist{0}.
Examples
if myattr = A,B,C and the delimiter is ,
then the result would be:
mylist{0} = A
mylist{1} = B
mylist{2} = C
if myattr = 20030210 and the format string is 4s2s2s
then the result would be:
mylist{0} = 2003
mylist{1} = 02
mylist{2} = 10
Related Transformers
You can also use the StringSearcher to split apart the values of attributes using regular expression pattern matching.
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.
Transformer Categories
Search FME Knowledge Center
Search for samples and information about this transformer on the FME Knowledge Center.