vbs script to compare matching records

February 23, 2010 at 07:22:02
Specs: Windows XP
I have two txt files both contain the field 'RecordID'. I want to be able run a script that works out a percentage match between to the two files based on the RecordID field.

See More: vbs script to compare matching records

Report •


#1
February 23, 2010 at 09:48:05
Okay. Let us know how that works out for ya.

Report •

#2
February 23, 2010 at 09:58:43
Can it be done?

Report •

#3
February 23, 2010 at 10:49:38
Probably.

Report •

Related Solutions

#4
February 23, 2010 at 10:54:06
ideas how, would be welcome.

Report •

#5
February 23, 2010 at 11:09:00
Rather not; you're rude.

Report •

#6
February 23, 2010 at 11:36:32
Sorry, it was not intentional. English is not my first language.

Report •

#7
February 23, 2010 at 12:34:02
You could start by posting details.
What do these files files look like?
Compare how?
How are the fields defined?
Percentage biased on what?

Report •

#8
February 23, 2010 at 13:24:57
e.g. comparing in the below example, recordID has 50% match

1.txt
recordID | field2 |field3
123456789 |acbde |2009
987654321 |tuvwx |2009

2.txt
recordID | field2 |field3
000456789 |xxbde |2009
987654321 |ksvwx |2010


Report •

#9
February 24, 2010 at 05:19:03
Are all the records in 1.txt guaranteed to be in 2.txt?
Are all the records in 2.txt guaranteed to be in 1.txt?

Report •

#10
February 24, 2010 at 07:10:04
thanks for the help. some in 1 are in 2, some in 2 are in 1. however both have some RecordIDs that are not in the other.

Report •

#11
February 24, 2010 at 14:47:42
i might be misunderstanding some things, but here's a stab at it. also, not clear if there can be "repeats" or not. assuming not.

@echo off>xfile & setlocal
set /a nn=0
:: file1 is taken to be the basis of the percentage.
for /f "skip=1 tokens=1 delims=|" %%a in (txt1) do (
set /a nn+=1
>> xfile echo %%a
)
for /f %%a in ('do findstr /L /b /g:xfile txt2 | find /c /v ""') set match=%%a
echo %match% out of %nn%
set /a perc=match*100/nn
echo percent: %perc%


Report •

#12
February 25, 2010 at 04:14:29
Great thread. Ow, I have a program that needs to be written, can somebody write it ?

Report •

#13
February 25, 2010 at 04:33:06
tvc - what kind of program is it?, i might know someone who can help. can you give more information.

Thank you nbrane that's got me there in the end.


Report •

Ask Question