Collection Filter

davidh

New Member
Hi all,

I am reading a text file, always containing a header and footer line and some error entries. I already have all single lines available in a collection (see screenshot - Split lines). Now I want to filter out the header and footer and separate the lines , in the end I want to have all error entries in a collection (see screenshot - FilteredSplit Values). I tried it with "filter collection" and a subsequent "split line" but I struggled with both.
 

Attachments

  • Split lines.PNG
    8 KB · Views: 42
  • FilteredSplit Values.PNG
    7.9 KB · Views: 42

VJR

Well-Known Member
Hi davidh,

You will get help from this post here based on what you are trying to achieve. Although it is slightly different but is similar to your requirement.
In that post the words are separated using "?:", but in your case it should be a space " ".

The splitting part should be as below. Here I have used an input from a data item but in your case it should be from the collection when you are looping through it.
View attachment 1532599668276.png

Find Last Space Position:
View attachment 1532599731168.png

Split all 3 words:
Trim(Mid([Input], 1, InStr([Input], " ")-1))
Trim(Mid([Input], InStr([Input], " ")+1, [LastSpacePosition]-InStr([Input]," ")))
Trim(Right([Input], Len([Input]) - [LastSpacePosition]))
View attachment 1532599773690.png
These are working fine in first instance for the input I have provided. Test it against various scenarios you have.

Output:
View attachment 1532599922156.png

You can maintain a counter data item as you loop through the Collection.
When the counter is 1 it indicates the 1st row of the collection which is when you will delete that row using the 'Delete Row' action of Collection Internal Object (not collection manipulation).

When the counter reaches the last row you will do the same. You will get the number of rows in the collection using the 'Count Rows' action of the internal object. When the counter reaches that number then it is time to delete.

Whenever the counter reaches the first and last row, there is no need to allow the diagram to pass through the above InstrRev and Multi Calc stages.
 
Top