chilecayenne
Programmer
Hi all,
I'm trying my hand at awk again, but just can't seem to get things going. I'm starting this to try to load one file into a 2x dimensional array, and in the body, search it to match on fields of the file I'm processing and append some values for output.
This is in the early stages...just trying to access the multi-dimensional array in the body.
It appears to be getting loaded in the BEGIN section...print statements show the values, and even the score from the array with the values for memrecnos in it.
BEGIN {
FS="|";
OFS="|";
while (getline < "test_link.txt" > 0)
{
split ($0,bxm_rec,"|");
b_memrecno1 = bxm_rec[2];
b_memrecno2 = bxm_rec[3];
b_score = bxm_rec[5];
bxm_array[b_memrecno1,b_memrecno2] = b_score;
}
}
#start main block
{
v_memrecno1 = $2
v_memrecno2 = $8
print "Memrecno1 = "$2" Memrecno2 = "$8"\n"
printf ("Score = %s\n",bxm_array[v_memrecno1,v_memrecno2])
#printf ("Score = %s\n",bxm_array[11,113521])
} #end of main block
However, when feeding it values from the input file (lets call it file2)...I get the following output:
Memrecno1 = 11 Memrecno2 = 113521
Score =
Memrecno1 = 29622 Memrecno2 = 46523
Score =
Memrecno1 = 33710 Memrecno2 = 45357
Score =
Memrecno1 = 36596 Memrecno2 = 47977
Score =
Memrecno1 = 36614 Memrecno2 = 47961
Score =
Memrecno1 = 37127 Memrecno2 = 37142
Score =
Memrecno1 = 37141 Memrecno2 = 45462
Score =
Memrecno1 = 37465 Memrecno2 = 56467
Score =
Memrecno1 = 37519 Memrecno2 = 46299
Score =
Memrecno1 = 37537 Memrecno2 = 47179
Score =
As you can see I've tried in one print statement (currently commented out) to hardcode values that I KNOW are in there, and have shown while using print statements in the array load section that they are going in there....
Any suggestions?
TIA,
chilecayenne
I'm trying my hand at awk again, but just can't seem to get things going. I'm starting this to try to load one file into a 2x dimensional array, and in the body, search it to match on fields of the file I'm processing and append some values for output.
This is in the early stages...just trying to access the multi-dimensional array in the body.
It appears to be getting loaded in the BEGIN section...print statements show the values, and even the score from the array with the values for memrecnos in it.
BEGIN {
FS="|";
OFS="|";
while (getline < "test_link.txt" > 0)
{
split ($0,bxm_rec,"|");
b_memrecno1 = bxm_rec[2];
b_memrecno2 = bxm_rec[3];
b_score = bxm_rec[5];
bxm_array[b_memrecno1,b_memrecno2] = b_score;
}
}
#start main block
{
v_memrecno1 = $2
v_memrecno2 = $8
print "Memrecno1 = "$2" Memrecno2 = "$8"\n"
printf ("Score = %s\n",bxm_array[v_memrecno1,v_memrecno2])
#printf ("Score = %s\n",bxm_array[11,113521])
} #end of main block
However, when feeding it values from the input file (lets call it file2)...I get the following output:
Memrecno1 = 11 Memrecno2 = 113521
Score =
Memrecno1 = 29622 Memrecno2 = 46523
Score =
Memrecno1 = 33710 Memrecno2 = 45357
Score =
Memrecno1 = 36596 Memrecno2 = 47977
Score =
Memrecno1 = 36614 Memrecno2 = 47961
Score =
Memrecno1 = 37127 Memrecno2 = 37142
Score =
Memrecno1 = 37141 Memrecno2 = 45462
Score =
Memrecno1 = 37465 Memrecno2 = 56467
Score =
Memrecno1 = 37519 Memrecno2 = 46299
Score =
Memrecno1 = 37537 Memrecno2 = 47179
Score =
As you can see I've tried in one print statement (currently commented out) to hardcode values that I KNOW are in there, and have shown while using print statements in the array load section that they are going in there....
Any suggestions?
TIA,
chilecayenne