|
Removing trailing blank records (method 3) |
Pipelines v1.6 |
.* Example by TenFiftyTwo(c). |
.* The following pipeline reads the file: example.txt and removes any trailing blank lines.* and displays the result on the console. .* There are a number of ways of identifying and removing trailing blank lines, however,.* this pipeline construction demonstrates the fastest and most efficient method as it only.* joins and buffers a non blank line followed by consecutive blank lines (1 byte each).* inorder to isolate a set of trailing blank records. pipe (endchar ?)
< &installdrive:\&installpath\Examples\Input\example.txt .* Read input file. | strip trailing .* Trim off whitespace. | a: locate .* Route out blank records. | specs xfe 1 1-* n .* Insert a x'fe' in column 1. | split after str xfe .* Split after the x'fe'. | b: faninany .* Merge the streams. | join until 1 xfe .* Collect blank records and join them to the end of the.. .* ..current non-blank record. | c: take last .* Isolate the last record. | change xff // .* Remove blank line indicators. This removes trailing.. .* ..whitespace from the end of the last record.. .* ..(where each x'ff' represents a trailing blank line!). | d: faninany .* Merge the streams. | split before str xff .* Split the records just before x'ff's | change xff // .* Remove blank line indicators. | cons .* Display on the console. ? a: | specs xff 1 .* Mark a blank line with a x'ff' character. | b: .* Route back to main pipeline. ? c: | take * .* Handle all but the last input record. | d: .* Route back to main pipeline.