I am working on ingesting pricing logs. A sample of the data I am ingesting looks like this:
D|535|00846U101|256||100|0.0001 1 0.01
B|1|1523318400.0108|62.28|1|72.21|1|0|k||200000005449000
B|2|1523318400.0245|62.28|1|||0|k||200000016741000
R|3|1523318400.1268|53.69|1|t|65.69|2|t|200000118254000
B|4|1523318400.151|53.69|1|t|||t|200000141347000
B|5|1523358000.0683|49.72|2|k|68|1|k|70000043528000
D|838|1523358000.9202|47.85|1|75|1|0|p||70000881083000
B|1|1523318400.0108|62.28|1|72.21|1|0|k||200000005449000cR|2|1523318400.0245|62.28|1|||0|k||200000016741000
R|3|1523318400.1268|53.69|1|t|65.69|2|t|200000118254000
B|4|1523318400.151|53.69|1|t|||t|200000141347000
D|338|1523358000.9202|47.85|1|75|1|0|p||70000881083000
R|1|1523318400.0245|62.28|1|||0|k||200000016741000
R|2|1523318400.1268|53.69|1|t|65.69|2|t|200000118254000
B|3|1523318400.151|53.69|1|t|||t|200000141347000
The first column identifies the type of log, and the bolded lines (D) serve to provide more information about the logs that follow. The second column is the log sequence (unless the first column is D; in that case, the second column is a sort of identifier number for D records). For all logs that have either 'R' or 'B' in the first column, their sequence number ascends numerically until the next 'D' record appears. Then, after that 'D' (which essentially labels a new log starting), the sequence restarts for the R or B records.
What I need is to be able to attach (tag) the information from the 'D' record to all of the 'R' and 'B' logs below that 'D' until the next 'D,' then repeat this pattern for the entire set of data.
I can give more context if necessary. Thanks!