Calculate the unique metrics in a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karry086
    New Member
    • Feb 2013
    • 4

    Calculate the unique metrics in a file

    For e.g. i have a log file in which there are many entries for appGUID. Now how many appGUID's are there, for this i have a code, but how many of them are unique, for this i don't have code. Please can anyone help me on this.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    This is not a code writing service but if you post the code you've tried along with a description of the problem you're having with it, we can help guide you to a solution.

    Comment

    • karry086
      New Member
      • Feb 2013
      • 4

      #3
      I have a perl script that finds the number of unique users in a log file by calling the function 'print_unique_u sers'. Following is the perl script :

      Code:
      function num_unique_users() {echo `print_unique_users 0 | gawk -F"," '{counts[$1]+=1}; END { print length(counts)}'` }
      Now this same logic i want to apply in C sharp language. Can you help ?
      Last edited by Rabbit; Feb 20 '13, 03:46 PM. Reason: Please use code tags when posting code.

      Comment

      • karry086
        New Member
        • Feb 2013
        • 4

        #4
        Actually i wanted to parse logs to find unique entries in a file for a particular field. My file has the log entries in following format :

        User:ashishg appGUID: wx
        User:weqeld appGUID: c09d24cb-bb4f-422b-963a-9cbd00d203cc
        User:weqeld appGUID: c09d24cb-bb4f-422b-963a-9cbd00d203cc
        User:gulanand appGUID: wx
        User:gulanand appGUID: wx

        Now i wanted to calculate unique appGUID/User from this log file. How can i do that using C sharp program ?

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          Please use code tags when posting code.

          The general algorithm to deduplicate a series of values is this:
          0) Create an array
          1) Loop through each value
          2) Check if the value is in the array
          3) If not, add it to the array

          Comment

          Working...