Connecting Tech Pros Worldwide Forums | Help | Site Map

Simple question regarding opening/finding/saving data in text files.

Ponder
Guest
 
Posts: n/a
#1: Jul 17 '05
Okay here's the scenario:

I have two big lists of numbers. One number on each line (they're telephone
numbers if that helps.) What I want to do, is have VB search through
list2.txt for numbers that are also in list1.txt and delete them. I would
usually sit and figure this out myself but I have the flu and I know how
helpfull you guys are :P~

Thanks in advance to anyone that can help.

-Ben-



Miles
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Simple question regarding opening/finding/saving data in text files.




Ponder[color=blue]
> Okay here's the scenario:
>
> I have two big lists of numbers. One number on each line (they're telephone
> numbers if that helps.) What I want to do, is have VB search through
> list2.txt for numbers that are also in list1.txt and delete them. I would
> usually sit and figure this out myself but I have the flu and I know how
> helpfull you guys are :P~[/color]

How big are the files? If they are small a simple sequential loop
through list2 for each number in list1. Not efficient but simple to
code. If the lists are too large for that, then a better way would be
to sort list2 and use a hashing routine to find each number contained in
list1. That would require list2 to either have fixed width records, or
use a seperate index file of pointers to each record.

J French
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Simple question regarding opening/finding/saving data in text files.


On Sat, 6 Dec 2003 17:59:25 -0000, "Ponder"
<ponder_public@yahoo.<NOSPAM>co.uk> wrote:
[color=blue]
>Okay here's the scenario:
>
>I have two big lists of numbers. One number on each line (they're telephone
>numbers if that helps.) What I want to do, is have VB search through
>list2.txt for numbers that are also in list1.txt and delete them. I would
>usually sit and figure this out myself but I have the flu and I know how
>helpfull you guys are :P~
>
>Thanks in advance to anyone that can help.[/color]

1) Pull the numbers into an Array

2) Sort them

3) Work through both lists comparing for <, =, >

You may be better off sorting the lists on disk if they are huge, and
then Line Input ing the numbers

For text file sorting see:

www.jerryfrench.co.uk/dsortv.htm
Steve Gerrard
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Simple question regarding opening/finding/saving data in text files.



"Ponder co.uk>" <ponder_public@yahoo.<NOSPAM> wrote in message
news:3fd2187f$0$13883$afc38c87@news.ukonline.co.uk ...[color=blue]
> Okay here's the scenario:
>
> I have two big lists of numbers. One number on each line (they're[/color]
telephone[color=blue]
> numbers if that helps.) What I want to do, is have VB search through
> list2.txt for numbers that are also in list1.txt and delete them. I[/color]
would[color=blue]
> usually sit and figure this out myself but I have the flu and I know[/color]
how[color=blue]
> helpfull you guys are :P~
>
> Thanks in advance to anyone that can help.
>
> -Ben-
>
>[/color]

Another option would be to import both lists into an Access database.

One simple left join query between the two would give you all the
numbers in List2 that are not in List1, which you could use to create a
third table called List2Cleaned. The SQL might look like this:

SELECT List2.PhoneNumber INTO List2Cleaned
FROM List2 LEFT JOIN List1 ON List2.PhoneNumber = List1.PhoneNumber
WHERE (((List1.PhoneNumber) Is Null));

Then export List2Cleaned as text again if you need it as a text file.

Putting indexes on both PhoneNumber fields will speed up the process for
long lists. That takes one click in Access, versus coding your own in
VB.

This is one area where Access is actually a pretty useful tool. It took
me maybe two minutes to dummy up a sample so I could build the query
shown above.



Closed Thread


Similar Visual Basic 4 / 5 / 6 bytes