Log file data mining

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • David R
    New Member
    • Dec 2008
    • 14

    Log file data mining

    I am writing an application in .net 1.1 using c#.
    I need to read and store data from a log file.
    The log file has 3 types of information:
    -the date
    -the time
    -the event
    All 3 are on seperate lines.
    I can open the file and read each line.

    Any suggestions on the collection I should use to store this information?
    I will need to report information from this data.
    i.e. the of occurances of a specific event
    i.e. times between certian events
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Consider using a DataBase, XML file, or CSV file that you can easily parse or select from.

    Comment

    • David R
      New Member
      • Dec 2008
      • 14

      #3
      So storing the log file to an xml file would be better than an arraylist?
      Do you have an example?

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        When you say store, do you mean write to disk, or store in your program in memory....there 's a big difference.

        Frinny's suggestions are aimed at persistent storage.

        Comment

        • David R
          New Member
          • Dec 2008
          • 14

          #5
          Sorry, I mean store in my program. I do not need to store to a db.

          I'm looking for the best way to read the log file and then do some calculations.
          ie. number of occurances, times between certain events, etc

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            Write a simple class with those properties. Then store your data in a List<YourClass> .

            Comment

            • David R
              New Member
              • Dec 2008
              • 14

              #7
              can u give an example?

              Comment

              • Curtis Rutland
                Recognized Expert Specialist
                • Apr 2008
                • 3264

                #8
                Sure. Your class would look something like this:
                Code:
                public class LogEntry
                {
                    public DateTime DateAndTime;
                    public string Event;
                    LogEntry(DateTime dAndT, string e)
                    {
                        DateAndTime = dAndT;
                        Event = e;
                    }
                }
                And your collection would look something like this:
                Code:
                System.Collections.ArrayList list = new System.Collections.ArrayList();
                Add items to your collection using list.Add.

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  Originally posted by insertAlias
                  And your collection would look something like this:
                  Code:
                  System.Collections.ArrayList list = new System.Collections.ArrayList();
                  Add items to your collection using list.Add.
                  Or instead of using an ArrayList you can use a List(Of LogEntry)....th is lets you be more specific about the types of objects in your list.

                  Comment

                  • Curtis Rutland
                    Recognized Expert Specialist
                    • Apr 2008
                    • 3264

                    #10
                    I had thought of that, but I'm pretty sure that doesn't exist in 1.1 :(

                    In C# it's List<LogEntry>

                    Comment

                    • Frinavale
                      Recognized Expert Expert
                      • Oct 2006
                      • 9749

                      #11
                      Originally posted by insertAlias
                      I'm pretty sure that doesn't exist in 1.1 :(

                      I had thought of that, though in C# it's List<LogEntry>
                      1.1 was ages ago!
                      I can't even remember that far back!

                      You're right the List(T) Class doesn't exist in the 1.1 Framework: just 2.0 and forward (Generics are so helpful!)

                      Comment

                      • David R
                        New Member
                        • Dec 2008
                        • 14

                        #12
                        Thank You.
                        One last question -
                        Like I said, I'm using 1.1 for a stand alone windows app. No db.
                        Just reading/writing to a file.

                        Are there any benefits to upgrading to .Net 2 or even 3?

                        Comment

                        • Frinavale
                          Recognized Expert Expert
                          • Oct 2006
                          • 9749

                          #13
                          Originally posted by David R
                          Thank You.
                          Are there any benefits to upgrading to .Net 2 or even 3?
                          Simply put: Yes.

                          There are many new features that will make your life (as a developer) much easier. Some new controls have been added as well that can also make the end user experience more enjoyable as well. Check them out for yourself :)

                          However, if you're just reading and writing files...then there's no need to upgrade....unle ss of course you're working with XML documents.

                          In general I would strongly recommend upgrading to 3.5 because of the benefits it offers (LINQ is probably one of the most powerful)

                          Comment

                          • Curtis Rutland
                            Recognized Expert Specialist
                            • Apr 2008
                            • 3264

                            #14
                            I would say yes as well. Especially if you are doing database stuff...

                            And if you go to .NET 3, you might as well go to .NET 3.5. It has all kinds of great tools. Plus, Visual Studio 2008 is just soooo much better than VS.NET

                            Comment

                            • David R
                              New Member
                              • Dec 2008
                              • 14

                              #15
                              getting back to my collection question -
                              so I will have 2 variable from the LogEntry class; a DateTime and Event string.
                              How do I add them both to a Arraylist?

                              Comment

                              Working...