Iterate through comma-separated values
- Last UpdatedJul 24, 2025
- 1 minute read
- PI System
- PI Connector for UFL 1.3.2.139
- Connectors
Before the 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 , 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 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)