Hello Team,
I am writing a script that reads a text (say 1.txt - 2 s2 a+bb means Number State Label) file having data as:
2 s2 a+bb
3 s3 a+bb
4 s4 a+bb
And there is another text file (say 2.txt) that has sample data as;
~x "a+bb"
<BEGIN>
<TOTAL> 3
<STATE> 1
~y "S_2"
<STATE> 2
~y "S_6"
<STATE> 3
~y "S_4"
~z "Z_t"
<END>
~y "S_2"
<FIRST> 4
5.66 5.66 6.66 7.33
<SECOND> 4
1.23 4.55 4.55 4.55
~y "S_6"
<FIRST> 4
5.66 5.66 6.66 7.33
<SECOND> 4
1.23 4.55 4.55 4.55
~y "S_4"
<FIRST> 4
5.66 5.66 6.66 7.33
<SECOND> 4
1.23 4.55 4.55 4.55
My script should be that on reading file 1.txt, it searches 2.txt for label "a+bb" (unique and not patterns like a+bb+c), reads <STATE>2 and then read <FIRST> and <SECOND> tags 2 times to give output as <FIRST><SECOND><FIRST><SECOND> i.e; as 5.66,5.66,6.66,7.33,1.23,4.55,4.55,4.55,5.66,5.66,6.66,7.33,1.23,4.55,4.55,4.55. These will all be comma separated like an array which I will use in my program later.
After this,it again reads second line in 1.txt (3 s3 a+bb), searches again label "a+bb" and read <STATE>3 (as given s3 in 1.txt) and append <FIRST><SECOND><FIRST><SECOND><FIRST><SECOND> 3 times (as given 3 in column 1 in 1.txt) with previous array. It repeats till 1.txt has all line traversed,
I am very much stuck in this part of my program. If any one help me out, I shall be very thankful.
Thanks.