In csv file search concern number for particular text from second column and add

I have main two csv files as follows:

file1.csv

731,dev-servers.com.,A,192.168.0.10
598,test-servers.com.,A,192.168.0.12
599,test1-servers.com.,A,192.168.0.11

file2.csv

dev-servers.com.,A,192.168.0.10
test-servers.com.,A,192.168.0.12
test1-servers.com.,A,192.168.0.11

I am looking for command to search in column2(file1) with column1(file2) and find the appropriate correct value and add to file2.

expected output:

file2.csv

731,dev-servers.com.,A,192.168.0.10
598,test-servers.com.,A,192.168.0.12
599,test1-servers.com.,A,192.168.0.11

@reach2me,
sounds like a very straight forward objective. There're plenty of similar threads almost everywhere including this forum. Have you search for anything similar yet?

Anything you've attempted on your own yet? Please, do share.

no idea! could you please share.

@reach2me,
I'd suggest you spend a bit of time searching this forum for related terms in your thread topic, e.g. csv match or some such.
Give it a whirl and see if you can find any valuable/promising leads first.
You probably won't find the exact "match" for your objective, but there should be something very similar you can use as a starting point and go from there.

Do come back with where you are in your way forward.

From the data given, cat file1.csv > file2.csv appears to be a valid solution (and totally pointless, as you already have file1.csv.

Presumably, the server names need not be in the same order in each file, and the A and the IP address would not be the same across the two files, and some of the server names might only be in file1 or file2, not in both.

It would help us visualise the actual requirements if you gave some real data that illustrated some of the corner cases you might have, together with the results you want.

It should also help you visualise how you would expect a solution might work (even on paper, not in code).

You might want to consider what action you should take when file2 contains a server name that is absent from file1. For example, you could ignore the problem, report it, and/or insert a special value so that the column layout is preserved.

There is a Search icon at top right. Try csv merge.

1 Like