Map data from 2 text files .. on Windows

0

I have 2 text files e.g. file1 and file2 file1 has column A that has a list of ID's e.g. ID1, ID2, ID3. Each ID has a few children e.g. ID1 has child1, child2, child3; ID2 has child4,child5 and so on ... Each child ID is uniq. file2 has column B that has a list if all childX defined in file1 along with other attributes e.g. location and etc. The task is: find mapping between ID from file1 and child ID from file2. In other words user wants to know that looking into file2 and seeing only child ID which ID's from file1 they came from ... Sorry if it's a little bit cumbersome . My question: I understand that it could be done programmatically e.g. using python or etc BUT could I use any Unix utility e.g. cygwin like grep or diff or etc in order to do this mapping? Thanks P.S. The point is: could it be done without scripting ... but just by running some unix utility. The task sounds to me like getting data by joining 2 tables.

susik

Posted 2016-09-30T02:40:30.160

Reputation: 447

looks on man join – matzeri – 2016-09-30T19:57:46.780

Thanks matzeri. This is exactly that I was looking ... Sorry I don't know how to mark this thread as solved. – susik – 2016-10-06T23:53:29.613

Answers

0

cygwin package coreutils provide the join command. As reported on
https://www.gnu.org/software/coreutils/manual/html_node/join-invocation.html#join-invocation

join: Join lines on a common field

join writes to standard output a line for each pair of input lines that have identical join fields. Synopsis:

join [option]… file1 file2

Either file1 or file2 (but not both) can be ‘-’, meaning standard input. file1 and file2 should be sorted on the join fields.

see link or man page for full usage.

matzeri

Posted 2016-09-30T02:40:30.160

Reputation: 1 662