Can I filter and sort email ids in notepad++ and other text editors


I have a txt file which has around 20000 email id. I want to know email count from gmail, yahoo, ymail, googlemail, aol, live,custom domain, gmx, and other temporary emails separately. And also i need to filter them and sort them in email domain order. How can i do that using notepad++? If any other program make this much easier than notepad ++ please refer that too.

Best Answer

I would do this in Excel

Copy the list into Column A of Excel. Excel will let you sort (and remove duplicates if needed).

From there, this macro will do it

Sub DoTheThing()


Dim row As Integer
row = 1

Do While (Range("A" & row).Value <> "")

    Dim emails() As String
    emails = Split(Range("A" & row).Value, "@")
    Dim domain As String

    Dim i As Integer

    'domain = emails(1)         commented out. Use this line if you want to include .com or .net
    domain = Split(emails(1), ".")(0)   'use this line if you want just the provider, such as GMAIL or Yahoo

    Dim resultsRow As Integer
    resultsRow = 1

    Dim resultExists As Boolean
    resultExists = False

    Do While (Range("C" & resultsRow).Value <> "")

        If (Range("C" & resultsRow).Value = domain) Then
            Range("D" & resultsRow).Value = Range("D" & resultsRow).Value + 1  ' add 1
            resultExists = True
        End If

    resultsRow = resultsRow + 1

    If (resultExists = False) Then
        Range("C" & resultsRow).Value = domain
        Range("D" & resultsRow).Value = 1
    End If

row = row + 1


End Sub

Code above assumes your original list is all lower case

Screen shots of before and after, showing the provider occurrences


enter image description here


enter image description here

Related Question