Forum Discussion

salonimaggo's avatar
salonimaggo
New Contributor
2 years ago
Solved

How to skip 5 lines after every fourth line in snaplogic text file.

I am reading one text file in snaplogic and have to skip unnecessary lines after every 4th line. 

  • Hello,

    You can group into an array and then:

    $myArray.filter((item, pos, a) => (a.indexOf(item)+1)%4 != 0)

    % is the MOD function.

    Hope it helps!

     

     

     

     

     

     

2 Replies

  • salonimaggo - While the solution provided by nativeBasic functionally works, I am concerned with the memory requirements when processing large files.  I recommend a slightly different approach using one of SnapLogic's built-in properties, specifically, the snap.in.totalCount property.  You can accomplish the same result using a Filter snap and allow your pipeline to work with the streaming data, rather than collecting the entire input file into memory.

    Hope this helps!

     

  • nativeBasic's avatar
    nativeBasic
    New Contributor III

    Hello,

    You can group into an array and then:

    $myArray.filter((item, pos, a) => (a.indexOf(item)+1)%4 != 0)

    % is the MOD function.

    Hope it helps!