removing-trailing-blank-records-3.rex |
Pipelines v2.1 |
.....|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....10... |
**** Top of file ****
1
2 /* The following pipeline reads the file: winston.txt and removes any trailing blank lines
3 and displays the result on the console.
4
5 There are a number of ways of identifying and removing trailing blank lines, however,
6 this pipeline construction demonstrates the fastest and most efficient method as it only
7 joins and buffers a non blank line followed by consecutive blank lines (1 byte each)
8 in order to isolate a set of trailing blank records. */
9
10 Address Rxpipe
11
12 'pipe (endchar ?)',
13 '< &installdrive:\&installpath\examples\input\winston.txt',
14 '| strip trailing', /* Trim off whitespace. */
15 '| a: locate', /* Route out blank records. */
16 '| specs xfe 1 1-* n', /* Insert a x'fe' in column 1. */
17 '| split after str xfe', /* Split after the x'fe'. */
18 '| b: faninany', /* Merge the streams. */
19 '| join until 1 xfe', /* Collect blank records and join them to the end.. */
20 , /* ..of the current non-blank record. */
21 '| c: take last', /* Isolate the last record. */
22 '| change xff //', /* Remove blank line indicators. This removes trailing.. */
23 , /* ..whitespace from the end of the last record.. */
24 , /* ..(where each x'ff' represents a trailing blank line!). */
25 '| d: faninany', /* Merge the streams. */
26 '| split before str xff', /* Split the records just before x'ff's */
27 '| change xff //', /* Remove blank line indicators. */
28 '| cons', /* Display on the console. */
29 '?',
30 'a:',
31 '| specs xff 1', /* Mark a blank line with a x'ff' character. */
32 '| b:', /* Route back to main pipeline. */
33 '?',
34 'c:',
35 '| take *', /* Handle all but the last input record. */
36 '| d:' /* Route back to main pipeline. */
37
38 Say 'Hit Enter to close..'
39 Parse Pull
40
41 Exit 0
**** End of file ****
|