Find matching values between 2 text files
Hi all,
Basically I am attempting to determine whether the first 2 columns (tab delimited file) from file1.txt match the first 2 columns of file2.txt. If they do I want to output the entire row of file1.txt to outputfile.txt...
I can do this using vbs but due to the amount of data that this is going to have to trawl through it's not an option. Can anyone please help?
Many thanks :)
leo002000
Junior Poster in Training
57 posts since Feb 2008
Reputation Points: 12
Solved Threads: 4
Many thanks for the time you have spent on this. Your assumption/logic is correct. I can get this to work on purely numerical data (as you have detailed below) but when I attempt to use them on my actual text files which look like this... I get empty outputfile.txt
Also I would like to print all the columns from file1.txt as shown in my example below (outputfile.txt)
file1.txt
Supercont 1.9 1479890 T 2 @ 1,3,5
Supercont 1.9 1459998 G 4 @.. 1,2,6
Supercont 1.8 1234876 C 6 @... 1,8
File2.txt
Supercont 1.9 1479890
Supercont 1.33 2343434
Supercont 1.4 0099879
Outputfile.txt
Supercont 1.9 1479890 T 2 @ 1,3,5
Many thanks for your help :)
leo002000
Junior Poster in Training
57 posts since Feb 2008
Reputation Points: 12
Solved Threads: 4
Yes your 100% correct. If if I was looking to find a match anywhere in the 2 columns, so say for example...
file1.txt
1 6
2 8
file2.txt
3 9
1 6
outputfile
1 6
and also how would I print the other columns associated with the match from file1.txt? say columns 1,2,3,4 which obviously I am not showing here...
Many thanks
:)
leo002000
Junior Poster in Training
57 posts since Feb 2008
Reputation Points: 12
Solved Threads: 4
Mike you are an absolute gent... It works a treat. Would it be possible to put in some additional commenting, so that I am able to get some of it into my head (particularly) the hashing bit...
Thanks a million
leo002000
Junior Poster in Training
57 posts since Feb 2008
Reputation Points: 12
Solved Threads: 4