cancel
Showing results for 
Search instead for 
Did you mean: 

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

salonimaggo
New Contributor

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

1 ACCEPTED SOLUTION

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!

Screenshot 2023-12-28 at 19.50.39.png

 

Screenshot 2023-12-28 at 19.51.10.png

 

 

 

 

 

View solution in original post

2 REPLIES 2

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!

Screenshot 2023-12-28 at 19.50.39.png

 

Screenshot 2023-12-28 at 19.51.10.png

 

 

 

 

 

koryknick
Employee
Employee

@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.

koryknick_0-1704372169013.png

Hope this helps!