AttributeSplitter
From fmepedia
AttributeSplitter is a Workbench Transformer.
| Table of contents |
Description
This transformer splits a given attribute, using a given delimiter character, into a list attribute. Each item in the list will contain a single token split from the list. 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.
The delimiter character can be expressed as a single character, or it may be a special character sequence beginning with a backslash ("\"). In that case, it is interpreted as specified in the following table. If the sequence is not listed in the table, then the backslash character is simply ignored.
Sequence Description \a Audible alert (bell) (0x07) \b Backspace (0x08) \f Form feed (0x0c) \n Newline (0x0a) \r Carriage return (0x0d) \t Tab (0x09) \v Vertical tab (0x0b) \\ Backslash \, Comma \/ Forward slash \ooo The digits ooo describe a character in octal notation. \xhh The digits hh describe a character in hexadecimal notation.
You can right-click on the resulting list and select Expose Element to access the individual elements in the list.
An example use of this transformer would be to break apart an attribute which has a comma-separated value list into its component pieces.
Example (splitting myattr into mylist): if myattr = A,B,C and delimiter is , (a comma) then the result would be:
mylist{0} = A
mylist{1} = B
mylist{2} = C
Example (splitting myattr into mylist): if myattr = 20030210 and delimiter is 4s2s2s then the result would be:
mylist{0} = 2003
mylist{1} = 02
mylist{2} = 10
The Grepper offers similar functionaly with regular-expression matching.
Example
The attached workspace shows an example use of the AttributeSplitter transformer.
In this example the Safe Software address is held as a single attribute - the aim is to split it up into individual component parts. (yes, the country and postcode fields have got an unintended space character in front of them)
Workspace Screenshot
