File parsing



10 abc
20 abcc
30 abcd
40 xycz
42 wxy
5 abc
20 abcd
30 abcc

So, What i intend to do is:
Build an array or associatiave array...
such as

During the first pass:
search for the "FIRST" occurances of column 2.
So it would be:
"abc" - 10
"abcc" - 20
"abcd" - 30
& so on...

During the second pass:
search for the "SECOND" occurance of column2 & modify the earlier
array as:
"abc" 10 - 5 = "abc" 5
abcc 20 - 30 = "abcc" -10

I know this is doable in just one pass,but i'm stuck at:

1. I read the ffirst occurance of "abc" (column 2) - abc 10
2. I can NOT read until the next occurance ot "abc"- abc 5
3. I can NOT come back a LINE after where i was at step 1.

Is there a better / quicker way to do this?

PS # this is not a homework question, nor this is a puzzle / interview
qn. :)

thanks in advance!

.



Relevant Pages

  • Re: File parsing
    ... Build an array or associatiave array... ... I can NOT read until the next occurance ot "abc"- abc 5 ...
    (comp.lang.awk)
  • Re: File parsing
    ... Build an array or associatiave array... ... I can NOT read until the next occurance ot "abc"- abc 5 ...
    (comp.lang.awk)
  • Re: File parsing
    ... I can NOT read until the next occurance ot "abc"- abc 5 ...
    (comp.lang.awk)
  • Re: Need help with user-written routine in SOR$
    ... > ADRS2 is the other record contents by reference ...
    (comp.os.vms)
  • Re: Unvollendetes read(STDIN_FILENO)
    ... Wenn ABC eine zusammenhängende Sequenz ist, ... einzelnes readgarantiert alles holt, also ABCD, und nicht ... mit einem generalisierten Terminal-Interface auskommt, ... fuer Unsinn Du Dir ausdenken kannst, um Deinen Unwillen, es richtig zu ...
    (de.comp.os.unix.programming)