Thank you, Don.
I see your point. I will post my data clearly in the next post.
Best,
Jaeyoung
---------- Post updated 12-18-15 at 05:32 PM ---------- Previous update was 12-17-15 at 07:24 PM ----------
Thank you for all your help, Don and RudiC.
I have revised your elegant code a bit for my work.
Now, the updated code works successfully to calculate average values. I would appreciate your help.
I have a question about skipping non-data line. I tried Don's comment (/[{}]/), but it copied non-data lines on the top while remaining the original non-data lines. In addition, a few non-data string is changed to '0'. I marked in red in the following result.
Result.txt
cell (AND2X1_RVT) {
timing () {
cell_rise ("del_1_7_7") {
}
rise_transition ("del_1_7_7") {
}
cell_fall ("del_1_7_7") {
}
....
cell (AND2X1_RVT) {
timing () {
related_pin : "0, ";
timing_sense : "0, ";
cell_rise ("del_1_7_7") {
index_1("0.016,0.032,0.064,0.128,0.256,0.512,1.024, ");
index_2("0.1,0.25,0.5,1,2,4,8, ");
values("1.5,3,4.5,6,7.5,9,10.5, ", \
"12,13.5,15,16.5,18,19.5,21, ", \
"22.5,24,25.5,27,28,30,31.5, ", \
"33,34.5,36,37.5,39,40.5,42, ", \
"43.5,45,46.5,48,49.5,51,52.5, ", \
"54,55.5,57,58.5,60,61.5,63, ", \
"64.5,66,67.5,69,70.5,72,73.5, ");
}
rise_transition ("del_1_7_7") {
index_1("0.016,0.032,0.064,0.128,0.256,0.512,1.024, ");
index_2("0.1,0.25,0.5,1,2,4,8, ");
values("75,76.5,78,79.5,81,82.5,84, ", \
"85.5,87,88.5,90,91.5,93,94.5, ", \
"96,97.5,99,100.5,102,103.5,105, ", \
"106.5,108,109.5,111,112.5,114,115.5, ", \
"117,118.5,120,121.5,123,124.5,126, ", \
"127.5,129,130.5,132,133.5,135,136.5, ", \
"138,139.5,141,142.5,144,145.5,147, ");
}
cell_fall ("del_1_7_7") {
}
.....
AWKscript.s
awk -F"\"" '
/[{}]/ {print # copy non-data lines
next # and skip remaining steps
}
FOUND {while (/\\$/) {getline X # if last line had "index_2", read and append
$0 = $0 X
}
FOUND = 0
}
#/^index_2("0.1, 0.25, 0.5, 1, 2, 4, 8"); / {FOUND = 1
/^cell_rise ("del_1_7_7") { / {FOUND = 1
}
FNR==NR {if ($2) T[FNR] = $2
next
}
FNR in T {n = split ($2, N, ",")
n = split (T[FNR], M, ",")
$2 = "\""
for (i=1; i<=(n); i++) $2 = $2 (M+(N-M)*0.5) ","
sub (/,$/, ", \"", $2)
}
1
' OFS="" FileA.txt FileB.txt
FileA.txt
....
cell (AND2X1_RVT) {
timing () {
related_pin : "A1";
timing_sense : "positive_unate";
cell_rise ("del_1_7_7") {
index_1("0.016, 0.032, 0.064, 0.128, 0.256, 0.512, 1.024");
index_2("0.1, 0.25, 0.5, 1, 2, 4, 8");
values("1, 2, 3, 4, 5, 6, 7", \
"8, 9, 10, 11, 12, 13, 14", \
"15, 16, 17, 18, 18, 20, 21", \
"22, 23, 24, 25, 26, 27, 28", \
"29, 30, 31, 32, 33, 34, 35", \
"36, 37, 38, 39, 40, 41, 42", \
"43, 44, 45, 46, 47, 48, 49");
}
rise_transition ("del_1_7_7") {
index_1("0.016, 0.032, 0.064, 0.128, 0.256, 0.512, 1.024");
index_2("0.1, 0.25, 0.5, 1, 2, 4, 8");
values("50, 51, 52, 53, 54, 55, 56", \
"57, 58, 59, 60, 61, 62, 63", \
"64, 65, 66, 67, 68, 69, 70", \
"71, 72, 73, 74, 75, 76, 77", \
"78, 79, 80, 81, 82, 83, 84", \
"85, 86, 87, 88, 89, 90, 91", \
"92, 93, 94, 95, 96, 97, 98");
}
cell_fall ("del_1_7_7") {
}
.....
FileB.txt
....
cell (AND2X1_RVT) {
timing () {
related_pin : "A1";
timing_sense : "positive_unate";
cell_rise ("del_1_7_7") {
index_1("0.016, 0.032, 0.064, 0.128, 0.256, 0.512, 1.024");
index_2("0.1, 0.25, 0.5, 1, 2, 4, 8");
values("2, 4, 6, 8, 10, 12, 14", \
"16, 18, 20, 22, 24, 26, 28", \
"30, 32, 34, 36, 38, 40, 42", \
"44, 46, 48, 50, 52, 54, 56", \
"58, 60, 62, 64, 66, 68, 70", \
"72, 74, 76, 78, 80, 82, 84", \
"86, 88, 90, 92, 94, 96, 98");
}
rise_transition ("del_1_7_7") {
index_1("0.016, 0.032, 0.064, 0.128, 0.256, 0.512, 1.024");
index_2("0.1, 0.25, 0.5, 1, 2, 4, 8");
values("100, 102, 104, 106, 108, 110, 112", \
"114, 116, 118, 120, 122, 124, 126", \
"128, 130, 132, 134, 136, 138, 140", \
"142, 144, 146, 148, 150, 152, 154", \
"156, 158, 160, 162, 164, 166, 168", \
"170, 172, 174, 176, 178, 180, 182", \
"184, 186, 188, 190, 192, 194, 196");
}
cell_fall ("del_1_7_7") {
}
.....
I have tried many time by myself, but I could not find a way to skip non-data lines correctly. Any suggestions? Thank you in advance.
Best,
Jaeyoung
Best,
Jaeyoung