• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Parse TEXT File??

Engaged ,
May 01, 2008 May 01, 2008

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

187

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 01, 2008 May 01, 2008

Copy link to clipboard

Copied

You can use cfhttp to convert your file variable to a query and use query of queries to count email adddresses.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2008 May 04, 2008

Copy link to clipboard

Copied

LATEST
Here is some sample code. Mind you, I have not checked it for efficiency.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation