|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Learn five alternative approaches for automating the delivery of Excel-based reports. Read all about it in the free whitepaper: “Automating Excel Reports: Five Approaches for Java Developers” Download Now!
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > What's wrong with this code? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|