Split using specs

Pipelines v1.6

 

.* Example by TenFiftyTwo(c).

Home

 
.* The following pipeline reads the input file: example.txt and cuts each input record into
.* three output records.
.* The first output record comprises the contents of columns 1 to 10 of the input record, the
.* second, are columns 11 to 20, and the third, are columns 21 upto and including the last
.* column of the input record.
.*
.* This example is intended to demonstate how you can produce multiple output records from
.* a single input record.
 
pipe (endchar ?)
     < &installdrive:\&installpath\Examples\Input\example.txt .* Read input file.
     | strip trailing              .* Trim off whitespace.
     | a: locate                   .* Send null records to second pipeline.
     | specs 1.10 1 write          .* Write record comprising cols 1-10.
             11.10 1 write         .* Write record comprising cols 11-20.
             21-* 1                .* Write record comprising cols 21 to end-of-record.
     | b: faninany                 .* Read from any stream. This will preserve order of blank records.
     | console                     .* Display on the console.
     ?
     a:
     | take *                      .* Accept null records and route..
     | b:                          .* ..back to FANINANY.