The majority of forums are now only available as archives, which means posting/editing is disabled.
The Anything and Everything forum is still open.
The Anything and Everything forum is still open.
comparing 2 files
|
|||
|
Rank: Unregistered
|
Hi,
I am having 2 files. I have to compare these 2 files a particular column and get the count how much is matching and how much is not matching. For eg., first file has 500 reords and the second file has 700 reords. Both files are having around 20 fieds separated by "|". FILE 1: ID|Name|Address|.........|||||.... 1+5e|jesica|37, cross street|...... 1+63e|albert|81, church avenue|.... FILE2: ID|Name|Address|.........|||||.... 1+78r|rene|92, pearl street|.............. 1+5e|jesica thame|37, cross street|...... 1+63e|albert|81, church avenue|.... In the above example, I have to compare the Name between the files as always rowid is unique betwwen the 2 files. For the above, the output should be Matching = 1 (because names of record 2 is matching exactly) and Non match = 1 (because names of reord1 is not matching). I tried with the below script. But I couldn't get it. Can anyone help me? Thanks in advance, jacob !#/usr/bin/perl open(FILE,"account_id.txt"); open (OUT, ">id_freq.txt"); $count = 0; while(<FILE>) { @arr=split(/\n/,$_); $first = @arr[0]; print "$first\t"; open(FILE1,"contacts.txt"); $count = 0; while(<FILE1>) { @arr1=split(/\|/,$_); $second = @arr1[1]; chomp($second); if($first eq $second) {print OUT "@arr1[0]\t@arr1[1]\t"; } if(@arr1[1] eq @arr1[1]) { print "1\n"; } }} |
||
|
|||
|
|||
|
Rank: ? (171)
Member #: 11947 |
heres my implimentation (i'm free typing so their might be some errors, i'll fix it when i have more time if still needed):
Code:
» Post edited 2004-12-20, 03:45pm by Umojan.
|
||
|
Please login or register to post a reply.
