Skip to main content
Inspiring
May 1, 2008
Question

Parse TEXT File??

  • May 1, 2008
  • 2 replies
  • 249 views
Hi,

I am using CF 8

I have a text file (mylog.txt) that currently stores login information for our users. I need to parse and extract some basic information from the file and I am having a hard time. I need to know the following

1. A list of all UNIQUE email addresses that appear in the text file.
2. A count of how many times each email address appears

Each time a user logs on a "new line" is entered in the text file. Here is some sample data:

[1/05/08 1:15:31 PM] User mark@abc.com logged in.
[1/11/08 3:57:30 PM] User john@def.com logged in.
[1/12/08 8:33:17 PM] User bobby@test.com logged in.
[2/17/08 6:37:07 AM] User sue@muppets.com logged in.
[2/19/08 3:57:30 PM] User john@def.com logged in.

I would like to parse the text file and then output my results to the screen. The output should look like this, note John logged in twice:

Email Address | Count
mark@abc.com 1
john@def.com 2
bobby@test.com 1
sue@muppets.com 1

The prior user here should have stored this in the database but for now I still need to get at this data.

Any help appreciated.

Thanks,

-Westside
This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
May 4, 2008
Here is some sample code. Mind you, I have not checked it for efficiency.

Inspiring
May 1, 2008
You can use cfhttp to convert your file variable to a query and use query of queries to count email adddresses.