Forum Discussion
Like any other development platform, there are many solutions; here is mine for this use case. Please download and decompress the attached zip file, then import the SLP file as a new pipeline. Update the File Reader with your filename and validate to ensure it is working properly. You will need to finish adding the fields to the last Fixed Width Formatter, but I was able to see that the first few are coming out properly.
The first Fixed Width Parser is skipping the first two lines to get rid of that initial header, then using the Ignore Lines table to skip over the other headers that repeat:
Now the returned records should only contain the data we need: 4 lines per "group". So we simply use the Group By N snap with a group size of 4 to push every 4 records into one document as an array.
From here, we use a Mapper snap to concatenate the 4 records into a single string. Note the use of the Array.reduce() method in the expression:
$group.reduce((accum,cur)=> accum.concat(cur.record), '')
Basically, this just starts with an empty string, and performs the String.concat() for each "record" element in the array.
Note that I've also configured the Target Path in the Mapper as $content and set the output view of the Mapper to "Binary", which allows me to send the records into the last Fixed Width Parser snap so it can be easily split into the actual data elements that you need for the rest of your processing.
Hope this helps!
Related Content
- 2 years ago
- 4 years ago
- 2 years ago