Removing trailing blank records (method 1)

Pipelines v1.6

 

.* Example by TenFiftyTwo(c).

Home

 
.* The following pipeline reads the file: example.txt and removes any trailing blank records.
.* All the records are combined together to form a single record, trailing whitespace is then removed,
.* finally, the combined record is split back into its constituent records.
 
pipe (endchar ?)
     < &installdrive:\&installpath\Examples\Input\example.txt .* Input file.
     | strip                              .* Remove whitespace.
     | specs /#/ 1 1-* n                  .* Prefix the record with a placement hash.
     | join *                             .* Combine all records.
     | strip trailing string /#/          .* Remove trailing placement chars.
     | split before str /#/               .* Extract each record.
     | strip leading string /#/           .* Discard the placement char.
     | cons                               .* Display on the console.