Actually I already have a python program to do this but this is too slow and error prone.
Since I already have a program, it will be easy for you to compete it.
The program does "Change the column x of file X (usually tab-delimited txt) to column y1 of file Y if column x of file X is in column y2 of file Y"
But this program causes "memory error" with large files especially when the output file is xlsx and too slow.
I hope you have good understanding and carefulness.
I will tell you more story after you post message.