Announcement

Collapse
No announcement yet.

Log parsing script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Log parsing script

    For those of you who are interested in this sort of stuff, I thought I'd share my script for extracting pricing information from my EQ log.

    What this bit of perl code does is take an EQ log file as standard input and generate, on standard output, a comma separated values table with the date the transaction occurred, the merchant's name, the name of the item, the price in copper pieces, whether it was a buy or a sell transaction, and whether the item purchased or sold was stackable.

    WARNING: This code only reports the amount of money that changed hands, and will only reflect the best price depending upon your character's faction and CHA, and merchant factors (greediness and traffic).

    WARNING: This code can not distinguish between an NPC merchant or a trader in the Bazaar. Use caution when examining the NPC names if you've traded in the Bazaar.

    WARNING: This code is provided as-is. I am not a programmer, so it's not good programming. It works for me. I will answer questions you might have about it here, but I will not "support" it. Use at your own risk, I'm not responsible if it blows up your computer, or if the blowing up of your computer scares your grandmother.

    [code:1]
    #!/usr/bin/perl
    print "Date,Name,Item,Price (cp),Buy/Sell,Stackable?\n";

    while (<>) {

    if (($month, $day, $year, $name, $buysell, $price, $stack, $item) = /\[.* (.*) (\d+) .* (\d+)\] (.*) (tells you.*ll be|tells you.*give you) (.*) (per|for the) (.*)'\cM/) {

    $date = $year.$month.$day;
    if ($buysell = /you$/) { $buy = "sell" } else { $buy = "buy" }

    ($pp) = $price =~ /(\d+) plat/;
    ($gp) = $price =~ /(\d+) gold/;
    ($sp) = $price =~ /(\d+) silver/;
    ($cp) = $price =~ /(\d+) copper/;
    $copper = 1000*$pp + 100*$gp + 10*$sp + $cp;

    $stack =~ s/per/yes/;
    $stack =~ s/for the//;
    $item =~ s/\.$//;
    $output = join ',', $date,$name,$item,$copper,$buy,$stack;

    print "$output\n";

    }
    }
    [/code:1]

    I've since taken this code and ported it to PHP with a file upload class so I can upload my log files through a web browser and a MySQL backend holding all the data.

    I am using these data in the EQTC database. If you would like to help with price reporting, send me a private message here, and we'll work out a way to get your log(s) to me. I'll run your log through the script, extracting only merchant data, send you a spreadsheet of your data, and then delete the log. I will not open my web upload form to the public for security reasons.

    I would share the php code, but it's highly modified to my environment. It's not too hard to port this code to php. If you don't have the perl regexp module for php, converting the regexp can be a little tricky. I'll include those here:

    [code:1]
    if (ereg ("\[.* (.*) ([[:digit:]]+) .* ([[:digit:]]+)\&#9 3; (.*) (tells you.*ll be|tells you.*give you) (.*) (per|for the) (.*)'[[:cntrl:]]&q uot;, $line, $values)) {
    [/code:1]
    [code:1]
    ereg ("(([[:digit:&#93 ;]*)[[:space:]]?pl atinum)?[[:space:]]?&# 40;([[:digit:]]*)& #91;[:space:]]?gold)?[ [:space:]]?(([&#91 ;:digit:]]*)[[:spa ce:]]?silver)?[[:space :]]?(([[:digit&#58 ;]]*)[[:space:]&#9 3;?copper)?", $values[6], $pp);

    $copper = 1000*$pp[2] + 100*$pp[4] + 10*$pp[6] + $pp[8];
    [/code:1]

    Ow, now I'm remembering the hours I spent on those last two. I'm glad perl regexps are nicer.
    Zallarenya
    Coercer of the Underfoot
    Druzzil Ro Server

  • #2
    Oh, and anyone is free to use, modify, and/or distribute this code. I'm not attaching my name to it, so no need to credit me
    Zallarenya
    Coercer of the Underfoot
    Druzzil Ro Server

    Comment


    • #3
      /em pulls out a DOS 6.1 manual and looks perplexed =P

      ok hun, I KNOW its prolly common knowledge, but for the code string you listed, what filename.extension do i name the file and then for a windows system, what command do I need to issue to run the script? or can I just double click the file? Since I dont see any file targeting in the script, I guessing that theres some parameter to target the correct log file?

      PERL expert I'm not. DOS, BATCH, VB, VBA, C++, XML, HTML pretty much ok with.

      Comment


      • #4
        #!/usr/bin/perl

        Is the format listing of a nix enviroment shell script, hence windows being obselete

        Comment

        Working...
        X