I have looked through several threads regarding merging files with awk and attempted using join however have been unsuccessful likely as I do not fully understand awk.
What I am attempting is to take a csv file which could be between 1 and 15,000 lines with 5 colums and another csv file that will between 1 and 200 lines and 2 colums and create a new file based on a match of field. The match pair is $5 in csv1 and $1 in csv 2.
Given the fact that fields in the last column of csv1 occur more than ones, I think it makes more sense that the join should be the other way around (the other way around it takes the last occurrence in column 5)
Thank you both for reply's and bare with me I want to make sure I understand so I don't have ask again.
{A[$1]=$2; next}
Is putting column 1 of file 2 in an array and make it variable $2?
next stop parsing file 2. {print $2, A[$5]}
Then print variable $2 and value of column 5 (a[$5] when it has a match from array$1 file 1 to a value in file 2?
A[$1]=$2 : Create an element for array A indexed by $1 (the first field in the line) and assign $2 (the second field)'s contents.
next stop processing THIS actual line in file2; read in and process next line until done with file2
print $2, A[$5] When processing the second file (file1), print its second field, and use fifth field as an index into array A, and, after OFS, print that value or an empty string if no element exists.