Reputation: 87
I have a large text file like this:
1
Power History Table ( 23-JUN-14 @ 10:48:39 )
starting core loading 140619~a
scan date and time 1406200700
ending core loading 140622~a
associated site L08 fission power 0.000000 0.000000 0.000
1 flux detector measured values for scan of 140620 for sites: E22 P18 L06
flux detector simulated shape from core 140619~a for sites: e22 p18 l06
-175.0 -140.0 -105.0 -70.0 -35.0 0.0 35.0 70.0 105.0 140.0 175.0
0.30E+15 ..................................................................................................... 0.30E+15
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . e l . l . . . . .
. . . . ee l . e .l . . . .
. . . . . . . e . . . .
. . . . l . . . . . . .
. . . e . . . . l . . . .
. . . . . . p . .e . . .
0.24E+15 ........................................p....................p....................................... 0.24E+15
. . . l . p . . . . . . .
. . . . . . . p . . . .
. . . . . . . . . . .
. . . p . . . . . . . .
. . . . . . . . . . .
. . . . . . . . p . . .
. . l . . . . . . e . .
. . . . . . . . . . .
. . . . . . .P . . . .
0.18E+15 ..................p..............P........................E.......................................... 0.18E+15
. . . . E . L . .L . . l . .
. . . . . . . . . . .
. . . . . . . . . p . .
. . . . . . . . P . . .
. . . . L . . . . . . .
. . . . . . . . . . .
. .e . . . . . . . . .
. . . . . . . . . . .
. .l . . P . L . L . . e . .
0.12E+15 ...........p............................L............................................................ 0.12E+15
. . L . P . . . . . . . .
. . . L . . . . . . l .
. . . . . . . . . p .
. . . . . . . . . L P .
. . P . . . . . . . L .
. . . . . . . . . . .
. .P . . . . . . . . .
. . . . . . . . . . .
. .L . . . . . . . . .
0.60E+14 ..................................................................................................... 0.60E+14
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . E . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . E . E . E . . .E E . .
0.0 ......................................................E........E....P................................ 0.0
-175.0 -140.0 -105.0 -70.0 -35.0 0.0 35.0 70.0 105.0 140.0 175.0
detector elevations
1
scan 140620 fission power at tpd 159258.0 total power 99.270
Triad3PC-ScanPower v1.1.1.1 ld=2007-03-27
--------------------------------------------------------------------------------------------------
burnup type: measbu lattice split: on discontinuity factors: normal
--------------------------------------------------------------------------------------------------
y z a b c d e f g h j k l m n o p q r s t
34 ... 34
33 ... ... ... ... 33
32 ... ... ... ... ... 32
31 ... ... ... ... ... ... 31
30 ... ... ... ... ... ... ... 30
29 ... ... ... 1.439 1.255 ... ... ... 29
28 ... ... 1.475 ... 1.185 ... ... 28
27 ... ... 1.383 ... ... ... ... ... 27
26 ... ... 1.371 ... ... 1.378 ... ... ... 26
25 ... ... 1.373 0.904 1.716 ... 0.721 ... ... ... 25
24 ... 1.178 ... 1.052 0.864 ... ... 0.594 ... 24
23 ... ... ... 0.895 ... 0.281 ... ... ... ... 23
22 ... ... ... 1.173 1.766 1.350 ... 0.614 ... 22
21 ... ... 1.347 ... 1.334 ... ... 0.676 1.231 ... 21
20 ... ... ... ... ... 1.726 1.713 ... ... ... ... 20
19 ... 1.053 0.953 1.395 0.329 ... 1.337 0.790 ... ... 19
18 ... ... 1.178 1.145 ... ... 0.338 1.062 ... 1.273 ... 18
17 ... 0.602 1.018 1.552 1.548 1.479 ... ... 1.260 ... 17
16 ... ... ... ... ... ... ... 1.377 0.767 1.206 ... 16
15 ... 1.231 ... 0.167 0.319 ... 0.315 0.803 ... ... 15
14 ... ... ... 1.336 ... 1.429 1.600 ... 1.245 1.381 ... 14
13 ... ... 0.876 0.314 1.567 1.726 1.261 ... 1.379 ... 13
12 ... ... 1.518 ... 0.164 ... ... ... ... ... ... 12
11 ... 1.435 0.971 ... 1.316 1.366 ... ... 1.483 ... 11
10 ... ... ... 1.007 1.174 1.048 ... 1.343 ... 10
9 ... ... ... 0.748 ... 1.227 0.759 ... ... ... 9
8 ... 1.375 ... ... 0.957 ... ... ... ... 8
7 ... ... 1.212 ... ... 0.793 0.647 1.264 ... ... 7
6 ... ... ... ... ... ... 1.048 ... ... 6
5 ... ... 1.205 ... ... ... ... ... 5
4 ... ... 1.140 ... 1.279 ... ... 4
3 ... ... ... ... 1.113 1.075 ... ... 3
2 ... ... ... ... ... ... ... 2
1 ... ... ... ... ... ... 1
0 ... ... ... ... ... 0
-1 ... ... ... ... -1
-2 ... -2
y z a b c d e f g h j k l m n o p q r s t
23-JUN-14 10:47:46
1
scan 140620 power-to-coolant at tpd 159258.0 total power 92.730
Triad3PC-ScanPower v1.1.1.1 ld=2007-03-27
--------------------------------------------------------------------------------------------------
burnup type: measbu lattice split: on discontinuity factors: normal
--------------------------------------------------------------------------------------------------
y z a b c d e f g h j k l m n o p q r s t
34 ... 34
33 ... ... ... ... 33
32 ... ... ... ... ... 32
31 ... ... ... ... ... ... 31
30 ... ... ... ... ... ... ... 30
29 ... ... ... 1.346 1.174 ... ... ... 29
28 ... ... 1.379 ... 1.108 ... ... 28
27 ... ... 1.293 ... ... ... ... ... 27
26 ... ... 1.282 ... ... 1.288 ... ... ... 26
25 ... ... 1.284 0.845 1.605 ... 0.674 ... ... ... 25
24 ... 1.102 ... 0.983 0.808 ... ... 0.556 ... 24
23 ... ... ... 0.837 ... 0.246 ... ... ... ... 23
22 ... ... ... 1.097 1.652 1.262 ... 0.574 ... 22
21 ... ... 1.260 ... 1.248 ... ... 0.632 1.151 ... 21
20 ... ... ... ... ... 1.614 1.602 ... ... ... ... 20
19 ... 0.985 0.891 1.305 0.288 ... 1.250 0.739 ... ... 19
18 ... ... 1.102 1.071 ... ... 0.296 0.993 ... 1.190 ... 18
17 ... 0.599 0.952 1.451 1.447 1.383 ... ... 1.178 ... 17
16 ... ... ... ... ... ... ... 1.287 0.718 1.127 ... 16
15 ... 1.151 ... 0.146 0.279 ... 0.276 0.751 ... ... 15
14 ... ... ... 1.249 ... 1.336 1.497 ... 1.164 1.292 ... 14
13 ... ... 0.819 0.275 1.466 1.614 1.179 ... 1.290 ... 13
12 ... ... 1.419 ... 0.144 ... ... ... ... ... ... 12
11 ... 1.342 0.908 ... 1.231 1.278 ... ... 1.387 ... 11
10 ... ... ... 0.941 1.098 0.980 ... 1.255 ... 10
9 ... ... ... 0.699 ... 1.147 0.710 ... ... ... 9
8 ... 1.286 ... ... 0.895 ... ... ... ... 8
7 ... ... 1.133 ... ... 0.741 0.605 1.181 ... ... 7
6 ... ... ... ... ... ... 0.980 ... ... 6
5 ... ... 1.126 ... ... ... ... ... 5
4 ... ... 1.066 ... 1.196 ... ... 4
3 ... ... ... ... 1.040 1.005 ... ... 3
2 ... ... ... ... ... ... ... 2
1 ... ... ... ... ... ... 1
0 ... ... ... ... ... 0
-1 ... ... ... ... -1
-2 ... -2
y z a b c d e f g h j k l m n o p q r s t
I'm trying to use Gawk to search the file and extract the line: scan date and time 1406200700 and the fission power map to another text file.
So the output should look something like this:
scan date and time 1406200700
scan 140620 fission power at tpd 159258.0 total power 99.270
Triad3PC-ScanPower v1.1.1.1 ld=2007-03-27
--------------------------------------------------------------------------------------------------
burnup type: measbu lattice split: on discontinuity factors: normal
--------------------------------------------------------------------------------------------------
y z a b c d e f g h j k l m n o p q r s t
34 ... 34
33 ... ... ... ... 33
32 ... ... ... ... ... 32
31 ... ... ... ... ... ... 31
30 ... ... ... ... ... ... ... 30
29 ... ... ... 1.439 1.255 ... ... ... 29
28 ... ... 1.475 ... 1.185 ... ... 28
27 ... ... 1.383 ... ... ... ... ... 27
26 ... ... 1.371 ... ... 1.378 ... ... ... 26
25 ... ... 1.373 0.904 1.716 ... 0.721 ... ... ... 25
24 ... 1.178 ... 1.052 0.864 ... ... 0.594 ... 24
23 ... ... ... 0.895 ... 0.281 ... ... ... ... 23
22 ... ... ... 1.173 1.766 1.350 ... 0.614 ... 22
21 ... ... 1.347 ... 1.334 ... ... 0.676 1.231 ... 21
20 ... ... ... ... ... 1.726 1.713 ... ... ... ... 20
19 ... 1.053 0.953 1.395 0.329 ... 1.337 0.790 ... ... 19
18 ... ... 1.178 1.145 ... ... 0.338 1.062 ... 1.273 ... 18
17 ... 0.602 1.018 1.552 1.548 1.479 ... ... 1.260 ... 17
16 ... ... ... ... ... ... ... 1.377 0.767 1.206 ... 16
15 ... 1.231 ... 0.167 0.319 ... 0.315 0.803 ... ... 15
14 ... ... ... 1.336 ... 1.429 1.600 ... 1.245 1.381 ... 14
13 ... ... 0.876 0.314 1.567 1.726 1.261 ... 1.379 ... 13
12 ... ... 1.518 ... 0.164 ... ... ... ... ... ... 12
11 ... 1.435 0.971 ... 1.316 1.366 ... ... 1.483 ... 11
10 ... ... ... 1.007 1.174 1.048 ... 1.343 ... 10
9 ... ... ... 0.748 ... 1.227 0.759 ... ... ... 9
8 ... 1.375 ... ... 0.957 ... ... ... ... 8
7 ... ... 1.212 ... ... 0.793 0.647 1.264 ... ... 7
6 ... ... ... ... ... ... 1.048 ... ... 6
5 ... ... 1.205 ... ... ... ... ... 5
4 ... ... 1.140 ... 1.279 ... ... 4
3 ... ... ... ... 1.113 1.075 ... ... 3
2 ... ... ... ... ... ... ... 2
1 ... ... ... ... ... ... 1
0 ... ... ... ... ... 0
-1 ... ... ... ... -1
-2 ... -2
y z a b c d e f g h j k l m n o p q r s t
My gawk command is:
gawk '/scan date and time/ && /fission power at tpd/ { 2;/ y z a b c/q;p;}' input.txt >> output.txt
But it doesn't seem to work, gawk just freezes and I have to Ctl-C to get out of it. I want gawk to stop at the second occurrence of the "y z a b c" column headings, not the first. But I think my syntax is wrong.
And I'm not sure if I should be using the && to search for two different strings. I've also tried || and that didn't work either. Using the "," just gives me everything between "scan date and time" and "Fission power at tpd", which I don't want.
Upvotes: 0
Views: 73
Reputation: 12887
Possible solution:
awk '
BEGIN {
prnt=0 # set print marker to 0 to begin with
}
/scan date and time/ {
print # print when we see the "first scan date and time"
}
/scan.*fission power/ {
prnt=1 # When we see the scan .. line begin print and so set print marker to 1
}
/(y z a b)/ {
fin++ # There is a y z a.... at the beginning of the required output and so set a counter
}
/([[:digit:]]+\:){2}[[:digit:]]+/ && fin==2 {
prnt=0 # When we see a line with a time and y z a... has printed twice, set the print marker to 0 to stop the printing
} prnt' file
One liner:
awk 'BEGIN { prnt=0 } /scan date and time/ { print } /scan.*fission power/ { prnt=1 } /(y z a b)/ { fin++} /([[:digit:]]+\:){2}[[:digit:]]+/ && fin==2 { prnt=0 } prnt' file
Upvotes: 1