G
gregarican
I am trying to create a routine that will parse a text file and break
down the various fields into an array. Here's the basic layout:
element1 | element2 | element3
element4 | element5 | element6
As you can tell it's pretty straightforward. I can just #split things
using the pipe as the delimiter. But every now and again the last
element on the line is actually thrown down to the next line, like:
element7 | element8 |
element9
element10 | element11 | element12
element13 | element14 |
element15
Can anyone suggest an easy way to parse things so that the "dangling"
elements are brought back to the preceding lines? In the example above
I would need to bring element9 up to the last pipe on the preceding
line. And same with bringing element15 to the last pipe on its
preceding line.
down the various fields into an array. Here's the basic layout:
element1 | element2 | element3
element4 | element5 | element6
As you can tell it's pretty straightforward. I can just #split things
using the pipe as the delimiter. But every now and again the last
element on the line is actually thrown down to the next line, like:
element7 | element8 |
element9
element10 | element11 | element12
element13 | element14 |
element15
Can anyone suggest an easy way to parse things so that the "dangling"
elements are brought back to the preceding lines? In the example above
I would need to bring element9 up to the last pipe on the preceding
line. And same with bringing element15 to the last pipe on its
preceding line.