Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI Connector for UFL

Iterate through comma-separated values

  • Last UpdatedJul 24, 2025
  • 1 minute read

Before the FOREACH() statement got introduced, dealing with comma-separated inputs with variable numbers of items (columns) was obstructive. The reason was because the input could contain a csv with x columns and during the next run it could have been different. With FOREACH(), the syntax is now more flexible, it is adaptable to the varying content of the csv input.

In order to simplify the overall syntax, the new function StoreEvents() got introduced. As the plural indicates, it takes collections in its parameters. See also StoreEvents in Learn about data storage in PI Points, AF elements and Event Frames.

The following example shows how to process a csv input that contains tag names on the first row and numeric, comma-separated values on all following rows.

Tag1,Tag2,Tag3,Tag4,Tag5,Tag6
0,1,2,3,4,5
10,11,12,13,14,15
0,1.1,2.2,3.3,4.4,5.5

[Tags]
Data.FILTER=C1=="Tag*"

TagNames = Clear()

FOREACH (CsvGetItem(__MESSAGE, ",")) DO

TagNames = Add(__ITEM)
ENDFOR

[Data]
Data.FILTER=C1=="*"

Values = Clear()

FOREACH (CsvGetItem(__MESSAGE, ",")) DO

Value_Number =__ITEM
Values = Add(Value_Number)
ENDFOR
StoreEvents(TagNames, ,NOW(), Values)

TitleResults for “How to create a CRG?”Also Available in