Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
Simple question regarding opening/finding/saving data in text files.
Old
  (#1)
Ponder
Guest
 
Posts: n/a
Default Simple question regarding opening/finding/saving data in text files. - 06-04-2007, 08:54 AM

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-


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Simple question regarding opening/finding/saving data in textfiles.
Old
  (#2)
Miles
Guest
 
Posts: n/a
Default Re: Simple question regarding opening/finding/saving data in textfiles. - 06-04-2007, 08:55 AM



Ponder
> 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~


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.

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Simple question regarding opening/finding/saving data in text files.
Old
  (#3)
J French
Guest
 
Posts: n/a
Default Re: Simple question regarding opening/finding/saving data in text files. - 06-04-2007, 08:55 AM

On Sat, 6 Dec 2003 17:59:25 -0000, "Ponder"
<ponder_public@yahoo.<NOSPAM>co.uk> wrote:

>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.


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
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Simple question regarding opening/finding/saving data in text files.
Old
  (#4)
Steve Gerrard
Guest
 
Posts: n/a
Default Re: Simple question regarding opening/finding/saving data in text files. - 06-04-2007, 08:55 AM


"Ponder co.uk>" <ponder_public@yahoo.<NOSPAM> wrote in message
news:3fd2187f$0$13883$EMAIL REMOVED ...
> 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-
>
>


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.



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top