2 files replace multiple occurances based on a match

Hi All,

I need some help trying to achieve the below but everything I've tried has failed, I have 2 files which i'm trying to carry out a match based on the first column from file 1, take that value find it in file 2 if found replace it with the second column from File 1

Lookup File: File 1

4110,RNXXX
2730,RBSAF
1500,RHYDI

File that requires replace function : File 2

1,4110,4110,,,4110,4110,4110,4110,4110,4110,
2,4111,4111,,,4111,4111,4111,4111,4111,4111,
3,,,,,,,,,,,
4,,,,,,,,,,,
5,4115,4115,,4115,4115,4115,4115,4115,4115,4115,
6,4116,4116,,4116,4116,4116,4116,4116,4116,4116,
7,4117,4117,,,4117,4117,4117,4117,4117,4117,
8,,,,,,,,,,,
9,4125,4125,,,4125,4125,4125,4125,4125,4125,
10,4126,4126,,,4126,4126,4126,4126,4126,4126,
11,4127,4127,,,4127,4127,4127,4127,4127,4127,
12,,,,,,,,,,,
13,4173,4173,,4173,4173,4173,4173,4173 2730 2734,4173,4173,
14,4174,4174,,4174,4174,4174,4174 2733,4174 2730,4174,4174,
15,4175,4175,,4175,4175,4175,4175,4175,4175,4175,

Any help you can offer would be much appreaciated.

Now, this is a problem that has been solved umpteen times in these forums, so the solution could be called a "standard method" or so.
Please show anything that you tried on your own, or even search results that could fit or were a "near miss".

RudiC, This is one of the methods i was trying but this didnt work. Any help or direction on where this has been solved previously would be appreacited.

Thanks

for i in $(cat file1.txt | cut -d, -f1)
do
replace=`grep $i file1.txt | cut -d, -f2`
cat file2.txt | sed 's/'$1'/'$replace'/g' >> file2_a.txt
done

I think you want $i not $1 in the sed expression.
Then, it is unprecise: a grep is searched in the whole line, can match on the wrong side. Can be improved by boundaries e.g. grep "^$i," file1.txt .
Last but not least, the files are read very often. It makes sense to look for more efficient solutions!