#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    56
    Rep Power
    13

    Question What's wrong with this code?


    I have an email list that has an email address on each line. The problem is that some emails appear more than once in the file.

    I'd like to parse out the dups and create a file of non-dups and a file of all the dups

    here' the code I have and it sure isn't working. Maybe my brain isn't working right today



    VB:
    Code:
    Set objFS=CreateObject ("Scripting.FileSystemObject" )
    Set listFile = objFS.OpenTextFile ("BADEMAILS.txt" )
    Set listFile1 = objFS.OpenTextFile ("BADEMAILS1.txt" )
    
    Set logfile = objFS.CreateTextFile("Final-Removed.txt" )
    Set logfile1 = objFS.CreateTextFile("Final-Removed-dups.txt" )
    
    count = 1
    Do While listFile.AtEndOfStream <> True
       line1 = listFile.ReadLine
       
       count1 = 1
       listFile1.open
       Do While listFile1.AtEndOfStream <> True
          line2 = listFile1.ReadLine
    
          If line1 <> line2 Then
             logfile.writeline line2
          Else 
            logfile1.writeline line2
          End If
    
          count1 = count1 + 1
       Loop  
    
       listFile1.close
    
       count = count + 1  
    Loop


    BADEMAILS.txt and BADEMAILS1.txt are identical. The only way I could think is to open one file and walk down each line while looping through a different file with the same content parsing out the dups?

    Any help would be appreciated

    Thanks
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    Namibia eh!
    Posts
    2
    Rep Power
    0
    Hi

    your logic is far from accomplishing what you desire.

    Try using a dictionary or collection to maintain a list of unique addresses.

    So your logic would look something like this...

    begin
    read address from maillist
    if address does not exist in collection
    ...add it to the collection
    else
    ...write a new line to Final-Removed-dups
    loop
    iterate the collection and write each item to Final-Removed

    HTH
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    56
    Rep Power
    13
    I think I'll do a non-programmatic way of importing the data into SQL Server then use the Query Analyzer to export the results to text using a simple select "distinct" query.

    Fast and simple

IMN logo majestic logo threadwatch logo seochat tools logo