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:
On the WBTSassignments1.txt file I have a few thousand lines each with 4 comma seperated fields:
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.
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% 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
I will start with an example of what I'm trying to do and then describe how I am approaching the issue.
File
PS028,005
Lexeme HRS # M #
PhraseType 1(1:1) 7(7)
PhraseLab 501 503
ClauseType ZYq0
PS028,005
Lexeme W # L> # BNH # M #... (17 Replies)
Hello,
I need to find out the minimum and maximum values based on specific column, and then print out the entire row with the max value.
Infile.txt:
scf6 290173 290416 . + X_047241 T_00113118-1
scf6 290491 290957 . + X_047241 T_00113118-2
scf6 290898 290957 . + X_047241 T_00113119-3
scf6... (2 Replies)
I need to add new ID to the file with old ID (column 7), I collected old ID / new ID pairs in a lookup file and I am trying to use awk to do the job, but something is not clicking.
My input file
ABC| 107|1440589221| -118.117167| 33.986333|10| 497476|1
ABC| 125|1440591215| -118.181000| ... (4 Replies)
Hello together,
i make something wrong... I want an array that contains information to associate it for further processing.
Here is something from my bash... You will know, what I'm trying to do.
I have to point out in advance, that the variable $SYSOS is changing and not as static as in my... (2 Replies)
Is there a reliable way to deal with whitespace in array indicies?
I am trying to annotate fails in a database using a table of known fails.
In a begin block I have code like this:
# Read in Known Fail List
getline < "'"$failListFile"'"; getline < "'"$failListFile"'"; getline <... (6 Replies)
Hi all
I have a problem where i have a large list ( up to 1000 of items) and need to have 2 items pulled from it into variables in a bash script
my list is like the following and I could have it as an array or possibly an external text file maintained separately. Every line is different and... (6 Replies)
I have an associative array named table
declare -A table
table="fruit"
table="veggie"
table="GT"
table="eminem"
Now say I have a variable returning the value highway
How do I find corresponding value GT ??
(this value that I find (GT in this case) is supposed to be the name of a mysql... (1 Reply)
Hi All,
I got stuck up with shell script where i use awk. The scenario which i am working on is as below.
I have a file text.txt with contents
COL1 COL2 COL3 COL4
1 A 500 400
1 B 500 400
1 A 500 200
2 A 290 300
2 B 290 280
3 C 100 100
I could able to sum col 3 and col4 based on... (3 Replies)
i have a file like this
< '393200103052';'H3G';'20081204'
< '393200103059';'TIM';'20110111'
< '393200103061';'TIM';'20060206'
< '393200103064';'OPI';'20110623'
> '393200103052';'HKG';'20081204'
> '393200103056';'TIM';'20110111'
> '393200103088';'TIM';'20060206'
Now i have to generate a file... (9 Replies)
Hi,
I am trying to make an associative array to use in a popup_menu on a website. Here is what i have:
foreach $entr ( @entries )
{
$temp_uid = $entr->get_value(uid);
$temp_naam = $entr->get_value(sn);
$s++;
}
This is the popup_menu i want to use it in.
popup_menu(-name=>'modcon',... (4 Replies)