sort by date

sort by date

2
NewbieNewbie
2

    Jan 27, 2005#1

    I have a webserver log that is not in order by date and was wondering if I could use ultra edit to sort the file by the date field?
    I need to make the ip field a standard length by adding leading zeros to makke each octet 3 numbers then sort the file by the date field. Can someone help me with this. this is a one time thing and I need to get it done i can paypal a little SPAM for the solution.
    thanks jr

    for example:
    128.135.x.x - - [16/Jan/2005:22:16:51 +0000] "GET /jibbajabba
    4.224.x.x - - [16/Jan/2005:22:15:29 +0000] "GET /foo
    63.24.x.x - - [16/Jan/2005:22:13:10 +0000] "POST /smart
    66.102.x.x - - [16/Jan/2005:22:15:08 +0000] "GET /some coffee

    21
    Basic UserBasic User
    21

      Jan 27, 2005#2

      I know you asked this in the UE forum but one allows excel to be used you'll be done in in less time than it will take to write this reply.

      paste your logfile text into into excel
      highlight column "a"
      click "data" "text_to_colums" "delimited"
      and put a "." in the "other" characer prompt.

      I would then do another text_to_columns on "d" delimited by "-"
      By now each of your ip numbers will be in their own columns.
      then highlight columns a/b/c/d
      click format cels "custom" type in 000 as the format mask.

      you now have your ip numbers zero filled.

      I would then continue with this same process,
      highlighting the column containing the text with the date and
      do several "text_to_columns" using [ and ] and + as the delimiters.
      once you have finished
      by now you have the date in its own field
      highight that column and click format cell and enter the date mask.

      your almost done.
      Highlight the entire file click "data" and "sort" and choose the desired column(s).

      Your now 99% of the way done.
      Have excell save the resultant data as a text file and use UE to restore the orginal records formatting...
      convert tabs to spaces,
      do global search/replace of two blanks for one blank.
      do some column editing to insert the "." between the IP figures.
      Enjoy.

      2
      NewbieNewbie
      2

        Jan 27, 2005#3

        thanks for the reply ....problem is this is a big weblog more than 65000 rows about (1 million) so excel wont do it....but thanks for taking a stab at it.

        21
        Basic UserBasic User
        21

          Jan 27, 2005#4

          THe following isn't a macro but it does what you requested...
          First format the IP addresses...
          click advanced edit
          tabstop value 6
          to a global search/replace put a check in regular expression, replace from top of file.
          find a "." replace with "^t." (neither expression has quotes its here simply in this note)

          click format "tabs to spaces"

          put yourself column edit mode (alt-c)
          Highlight first 3 cols of entire file.
          (a fast way put cursor in column 4 and hit ctrl-shift-end)

          Now right justify this highlighted text (click column "right justify")
          do a global search replace ON your SELECTION (see radion button)
          replacing a space " " with zero "0" (no quotes)

          Do this with all four of your Ip addresses.
          The IP address will now be zero padded but have embeded spaces.
          do a global search/replace of " ." with "." to get the spaces out of the IP addresses.

          lastly the tricky part about sorting the date within UE.
          The only thing that comes to mind is to do another column edit
          Highlight the three chars that form the month and
          replace (IN SELECTION)
          "jan" with "01"
          "feb" with "02"
          "mar" with "03"...

          once your done you can click "file" "sort" "advanced sort options"
          and fill in upto four keys which should work for you since
          year, month, day and time are all in their own columns.