The files are linked by the numbers: every K0000X in file A) is associated with a function in file B). The association is supported by the same number in the raw of the K0000X and the function. I need to have a new file like this:

Code:

K00001 BR:...the rest of the line K00002 PATH:...the rest of the line K00003 .... K00004 .... ....

So all the K0000N ID's and their associated function (BR: or PATH: depending on the related number). What makes it difficult is that in the file B) there all only 300 defined and unique lines (so 300 different function) but in file A) there are thousands of that K0000N ID's in multiple entry. In the new file I need to generate, I must have only single entries and if there are more numbers associated with K000N ID' in that case I should have something like that: Code:

K00001 funcition (releted to the 1st number) function (reletade to the second number) function (releted to the 3rd number) ...

Every K0000N should be in its own line with its associated function/functions (depending if comes in single or multiple entrie) separeted by tab.

I know it's very tricky but I hope some of you expert here could have an idea on how to do it.

Thanks in advance for any input

Code

PS: I posted just the intial line, but attachd you can find the two whole files.

Thank you so much! Quick and amazing script. Definitely it works! I have to say I wrote this thread in few different forums and everyone failed...you are the first person that was able to resolve my problem. Last question then I've completely solved the problem, do you know on the new file_C.txt obtained how to have something like that: