Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling data from .txt files

Status
Not open for further replies.

danmoss

Programmer
Feb 14, 2001
42
GB
My email server outputs a log file in the form of a .TXT file.
Is there a way to pull specific data from the file on a line-by line basis?
For example:-
The file outputs

Code:
User Name   No. Mails Sent  No. Mails Received  Mailbox Size
------------------------------------------------------------
Jo Bloggs         62                83               3Mb

I just need to get the details of the users name, mails sent and mails received, nothing else, and then display it.
Is this possible?
I am a newbie I'm afraid, so many apologies if this is really simple.
 
I usually pull these txt files into Excel and let it parse it... does a really good job. Then you can edit it there.

Mary :)
 
Unfortunately, our mail server will only output the files as .TXT files and we want the process to be automated.
We tried to open the files in excel directly, but the formatting was right out.
We're now looking into trying to port the info into an SQL table and then accessing that with ASP.
 
'FileSystemObject will read line by line:

dim objFSO
dim objFile
dim objReader
dim strLine

set objFSO = createObject("Scripting.FileSystemObject")
set objFile = objFSO.GetFile(YourFile)
set objReader = objFile.OpenAsTextStream(ForReading)
strLine = objReader.ReadLine
'strLine now contains the first line from the file
'Use a select statement of if...then...else
'Also,
Do While not objReader.AtEndOfStream
strLine = objReader.ReadLine
'Now you're iterating the entire file
loop
objReader.close
objFile.close
set objReader = nothing
set objFile = nothing
set objFSO = nothing


'Hope this helps! Let me know if you have other questions







 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top