Problem with lookup values on AWK associative array

I'm at wits end with this issue and my troubleshooting leads me to believe it is a problem with the file formatting of the array referenced by my script:

awk -F, '{if (NR==FNR) {a[$1]=$4","$3","$2}\
else {print a[$1] "," $0}}' WBTSassignments1.txt RNCalarms.tmp

On the WBTSassignments1.txt file I have a few thousand lines each with 4 comma seperated fields:

WTBS-1001,SE01001T,North Creek,Brad Bradford
WTBS-1002,SE01002D,Woodinville,Jon Johnson
WTBS-1003,SE01003A,Bothell,Rob Roberts

These assignment values are comming from an Excel spreadsheet. I've done a copy from Excel then pasted into a notepad document, saved as ANSI text document, then FTP it to the Linux server (they initially show up as "
ASCII English text, with CRLF line terminators
"). The array lookup does not work in this state.

Next I modified the EOL (perl -pe 's/\r\n|\n|\r/\n/g') to make them "ASCII text". The array lookup does not work in this state.

If I copy the values from the notepad document and paste directly into a new document using vi, the array lookup does not work.

If I open the document in vi, delete a line, then retype the exact same values manually the array lookup works. :confused:

I have this exact same array lookup working properly in another directory (in that case the WBTSassignments1.txt file type is "ASCII text") but it was recently migrated from a HP Unix server (where it was originally created). If I run: od -c WBTSassignments1.txt on the working and non-working files I don't see a difference in formatting, nor do I see a difference when I manually add lines in vi (in all cases the the only special character is /n).

I'm missing something here but don't know what it is.

Thanks in advance.

---------- Post updated at 03:26 PM ---------- Previous update was at 01:54 PM ----------

To troubleshoot this I created two files:
a.txt where I copied the entire WBTSassignments.txt file and deleted everything but the first 4 lines.
Then I copied a.txt to b.txt, deleted the first 2 lines, then manually retyped them in vi.

If I compare the two files it recognizes a difference, but I'm not sure how to see exactly what the difference is outside of hex.

jhamm% cat a.txt
WTBS-1001,SE01001T,North Creek,George Becker
WTBS-1002,SE01002D,Woodinville - Sprint,Scott Winecoff
WTBS-1003,SE01003A,VSTREAM - Bothell 7,George Becker
WTBS-1005,SE01005F,Little BearCreek-Cooper,Scott Winecoff

jhamm% cat b.txt
WBTS-1001,SE01001T,North Creek,George Becker
WBTS-1002,SE01002D,Woodinville - Sprint,Scott Winecoff
WTBS-1003,SE01003A,VSTREAM - Bothell 7,George Becker
WTBS-1005,SE01005F,Little BearCreek-Cooper,Scott Winecoff

jhamm% sdiff a.txt b.txt
WTBS-1001,SE01001T,North Creek,George Becker | WBTS-1001,SE01001T,North Creek,George Becker
WTBS-1002,SE01002D,Woodinville - Sprint,Scott Winecoff | WBTS-1002,SE01002D,Woodinville - Sprint,Scott Winecoff
WTBS-1003,SE01003A,VSTREAM - Bothell 7,George Becker WTBS-1003,SE01003A,VSTREAM - Bothell 7,George Becker
WTBS-1005,SE01005F,Little BearCreek-Cooper,Scott Winecoff WTBS-1005,SE01005F,Little BearCreek-Cooper,Scott Winecoff

The look the same in octal.

jhamm% od -c a.txt
0000000 W T B S - 1 0 0 1 , S E 0 1 0 0
0000020 1 T , N o r t h C r e e k , G
0000040 e o r g e B e c k e r \n W T B
0000060 S - 1 0 0 2 , S E 0 1 0 0 2 D ,
0000100 W o o d i n v i l l e - S p
0000120 r i n t , S c o t t W i n e c
0000140 o f f \n W T B S - 1 0 0 3 , S E
0000160 0 1 0 0 3 A , V S T R E A M -
0000200 B o t h e l l 7 , G e o r g
0000220 e B e c k e r \n W T B S - 1 0
0000240 0 5 , S E 0 1 0 0 5 F , L i t t
0000260 l e B e a r C r e e k - C o o
0000300 p e r , S c o t t W i n e c o
0000320 f f \n
0000323

jhamm% od -c b.txt
0000000 W B T S - 1 0 0 1 , S E 0 1 0 0
0000020 1 T , N o r t h C r e e k , G
0000040 e o r g e B e c k e r \n W B T
0000060 S - 1 0 0 2 , S E 0 1 0 0 2 D ,
0000100 W o o d i n v i l l e - S p
0000120 r i n t , S c o t t W i n e c
0000140 o f f \n W T B S - 1 0 0 3 , S E
0000160 0 1 0 0 3 A , V S T R E A M -
0000200 B o t h e l l 7 , G e o r g
0000220 e B e c k e r \n W T B S - 1 0
0000240 0 5 , S E 0 1 0 0 5 F , L i t t
0000260 l e B e a r C r e e k - C o o
0000300 p e r , S c o t t W i n e c o
0000320 f f \n
0000323

[/code]

But there is a slight difference in hexadecimal.

jhamm% od -h a.txt
0000000 5457 5342 312d 3030 2c31 4553 3130 3030
0000020 5431 4e2c 726f 6874 4320 6572 6b65 472c
0000040 6f65 6772 2065 6542 6b63 7265 570a 4254
0000060 2d53 3031 3230 532c 3045 3031 3230 2c44
0000100 6f57 646f 6e69 6976 6c6c 2065 202d 7053
0000120 6972 746e 532c 6f63 7474 5720 6e69 6365
0000140 666f 0a66 5457 5342 312d 3030 2c33 4553
0000160 3130 3030 4133 562c 5453 4552 4d41 2d20
0000200 4220 746f 6568 6c6c 3720 472c 6f65 6772
0000220 2065 6542 6b63 7265 570a 4254 2d53 3031
0000240 3530 532c 3045 3031 3530 2c46 694c 7474
0000260 656c 4220 6165 4372 6572 6b65 432d 6f6f
0000300 6570 2c72 6353 746f 2074 6957 656e 6f63
0000320 6666 000a
0000323

jhamm% od -h b.txt
0000000 4257 5354 312d 3030 2c31 4553 3130 3030
0000020 5431 4e2c 726f 6874 4320 6572 6b65 472c
0000040 6f65 6772 2065 6542 6b63 7265 570a 5442
0000060 2d53 3031 3230 532c 3045 3031 3230 2c44
0000100 6f57 646f 6e69 6976 6c6c 2065 202d 7053
0000120 6972 746e 532c 6f63 7474 5720 6e69 6365
0000140 666f 0a66 5457 5342 312d 3030 2c33 4553
0000160 3130 3030 4133 562c 5453 4552 4d41 2d20
0000200 4220 746f 6568 6c6c 3720 472c 6f65 6772
0000220 2065 6542 6b63 7265 570a 4254 2d53 3031
0000240 3530 532c 3045 3031 3530 2c46 694c 7474
0000260 656c 4220 6165 4372 6572 6b65 432d 6f6f
0000300 6570 2c72 6353 746f 2074 6957 656e 6f63
0000320 6666 000a
0000323

Apart from this one?

WTBS != WBTS

Wow, I spent 8 hours troubleshooting a misspelling? That is about as good a reason as any to call it a week.

Works great now, thanks!