For each line of the input file, in the format
(The first line - fld_1 - is a header line and only occurs as the first line in the file.)
I want to start at the end of the line and replace the first space with a '|'. I then want to continue toward the beginning of the line putting a '|' before each field except the first one. So, in the example above, the output file would look like
I've tried a couple of different approaches but I get into nested if-end if loops and get lost.
Note that field3 is optional - it may be there or it may not be. Also, for each input file, the starting columns should be the same ... but they may change depending on variable value lengths.
Comments/hints/thoughts appreciated as always.
Tnx.
Tom
"My mind is like a steel whatchamacallit ...
Code:
fld_1 fld_2 fld_3 fld_4
field1 field2 field3 field4
(The first line - fld_1 - is a header line and only occurs as the first line in the file.)
I want to start at the end of the line and replace the first space with a '|'. I then want to continue toward the beginning of the line putting a '|' before each field except the first one. So, in the example above, the output file would look like
Code:
field1|field2|field3|field4
I've tried a couple of different approaches but I get into nested if-end if loops and get lost.
Note that field3 is optional - it may be there or it may not be. Also, for each input file, the starting columns should be the same ... but they may change depending on variable value lengths.
Comments/hints/thoughts appreciated as always.
Tnx.
Tom
"My mind is like a steel whatchamacallit ...