parsing through a text file

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

Hello,

I'm in search for either sameple code or a msdn type walk through on how I
can go through a read file and figure out instances of a word. e.g. I've
read in an IIS log file and want to parse through it to find out how many
instances of an ip address? etc etc.... any help is appreciated.

thanks
Troy.
 
mike said:
I'm in search for either sameple code or a msdn type walk through on how I
can go through a read file and figure out instances of a word. e.g. I've
read in an IIS log file and want to parse through it to find out how many
instances of an ip address? etc etc.... any help is appreciated.

Open the file with StreamReader. Read it a line at a time with ReadLine
(until that returns null). For each line you read, do whatever
processing you need to (eg with String.IndexOf).
 
I would use RegularExpression along with FileStream and TextReader. You
would have to aggregate the IP addresses, so you would somehow have to do
group by IP address. Then, database may come in handy. But why parse through
IIS log while there are some good tools available?

WebLog Experts has a light version. Check it out here!

http://www.weblogexpert.com/lite.htm
 
Back
Top