On 25 November 2012 17:08, Shimon Lebowitz <[email protected]> wrote:
> Hi,
> I am not sure how to define this problem, but it sure LOOKS like something
> I should be able to do in pipes.
>
> Given: a data file, starting with a 'delimiter line', and with more of them
> distributed (in no known
> placement) throughout the data (but NOT as a final delimiter at the end of
> the file).
Are you serious that the delimited line is specified in the data, and
not in the code? If so, then what I do is (obviously) use "lookup" to
find the markers in the stream. The following to prefix the delimiter
with a * and the others with a blank
\ *:
| d: drop
| z: lookup detail | insert / /
| i: faninany ...
\ d: | insert /*/ | z:
If you know how to recognize the delimiters already, then use that in
the snippet below...
> Requirement: read the file, up to, but NOT including the second delimiter
> line (remember, the very first
> line of the file is also one), store those lines in a temporary file, and
> invoke an exec against that file.
> Then continue reading from the 2nd delimiter line, up to but not including
> the third one, store, run
> exec, etc. until EOF.
The easy way is a "sipping pipeline" like this:
signal on error
do forever
'peekto'
'callpipe (end \) *: | drop | strtolabel /*/ | substr 2-* | > temp file a'
address command 'EXEC ...'
end
There's more interesting ways, but this is probably the simplest.
| Rob