You are here: Working with FME Desktop > Working with Lists

Working with Lists

List attributes are FME's way of allowing multiple values per attribute.

Transformers often create a list automatically as part of the output from their particular process, usually when attributes from various different features are grouped into a single feature.

Note: FME lists can be displayed in an Inspector or by attaching a Logger transformer.

Typical lists look like:

mylist{0}

mylist{1}

There are many transformers that you can use to manipulate lists: see the Lists category in FME Workbench transformer gallery.

Very few output formats offer support for lists, so if you want to output the data to such a format, you'll need to manage the list first.

Tip: You should remove lists, especially ones with many items, as soon as you are finished with them. This will save memory and processing time and will reduce the clutter of your workspace.

Naming Conventions

Lists are indicated in Workbench by their name, followed by a pair of braces (for example, mylist{}).

Collections of attributes may be grouped together in a single FME feature using an attribute list. An attribute list element is just like any other attribute except that it contains an integer index enclosed in braces {} as part of its name.

A specific list element has its number between the braces:

mylist{0}

Complex lists can have multiple elements:

mylist{0}.myattribute

Note: Not all list elements have attributes. Sometimes a list element simply has a value (for example, a list generated by the AttributeSplitter).

By convention, the first element of a list has an index of 0.

For example, if a feature has these attributes on it:

    ids{0}  50

    ids{1}  45

    ids{2}  10

We would say that the feature has an unstructured list named "ids{}" with three elements. In FME Workbench, the list would be shown as part of a transformer output using its unqualified list name ids{}.  

If a feature has these attributes on it:

    overlaps{0}.direction  -1

    overlaps{0}.line_id    50

    overlaps{1}.direction  1

    overlaps{1}.line_id    22

    overlaps{2}.direction  1

    overlaps{2}.line_id    40

    overlaps{3}.direction  -1

    overlaps{3}.line_id    12

We would say that the feature has an structured list named "overlaps{}" with four elements. In FME Workbench, the list would be shown as part of a transformer output by using two unqualified names: overlaps{}.direction and overlaps{}.line_id.

Unqualified list names remind us that there are a number of actual attribute values present on the feature. However, it is not possible to directly access values from an unqualified list name. Instead, these names can be used as parameters to the various transformers that operate on lists. As well, by right-clicking on any unqualified list, a number of its elements may be exposed and from then on be accessed directly. Such attributes are called qualified list elements.

Exposing List Elements

Some transformers and data formats use FME “lists” to hold multiple attribute values. List transformers allow you to work with these lists.

Some transformers and readers/writers use FME “lists” to hold values that can “repeat”. If you want to access the particular pieces of a list, you can expose some of its elements by using the ListExploder or ListIndexer transformers so that you can work with the values.

For example, the results of a StringSearcher transformer can create a list. You may want to work with a certain element of that list, and therefore you would “expose” some elements.

To access specific list elements in Workbench, right-click on a list (e.g. mylist{}) in the attribute list and select Expose Elements. Then type in the number of elements you want to expose. List elements start counting at 0, so exposing 1 element of mylist{} will result in the extra attribute mylist{0} being available.

List elements can have other lists as part of their attributes:

mylist{}.secondlist{}

A ListConcatenator transformer can be used to convert an FME list to a comma-separated attribute value, i.e. :

mylist{0} A

mylist{1} C

to

attribute_list A,C