1
votes

If there is a match found (11032) in the file-1.txt based on File-2.txt then SET N (SET 6) from File-1.txt corresponding to that match should be inserted in the File-2.txt

File-1.txt
----------
SET 6 = 11032,13639,13984,13992
SET 7 = 14000,14008,14016

File-2.txt
----------
11032, 2.820E+02
13639, 2.490E+02
13984, 3.056E+02
13992, 3.172E+02
14000, 3.106E+02
14008, 2.819E+02
14016, 2.380E+02

Desired Output
--------------
SET 6,11032, 2.820E+02
SET 6,13639, 2.490E+02
SET 6,13984, 3.056E+02
SET 6,13992, 3.172E+02
SET 7,14000, 3.106E+02
SET 7,14008, 2.819E+02
SET 7,14016, 2.380E+02
What is your specific question? How to read a file? How to know if a line from one file matches a line in another file? How to insert content into a file? - John Gordon
For Example, the value 11032 in the file-2.txt matches with the file-1.txt then SET6 should be inserted before that value like it was shown in the Desired output file. - Srinivas R
Read file 2 into a dictionary. Then read file 1, and create the output file by looking up the values in the dictionary. - Barmar
I tried this ============ import pandas as pd a = pd.read_csv("File-2.txt", delimiter=",", header = None).to_dict()[0] print(a) Output ====== {0: 11032, 1: 13639, 2: 13984, 3: 13992, 4: 14000, 5: 14008, 6: 14016} - Srinivas R