Announcement

Collapse
No announcement yet.

Perl script to extract info from a log file

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

  • #16
    Just the slightest of bugs in eqbzrsold.pl:

    After:
    Code:
    # Print total for last item.
    print STDOUT "\t-----  ----------\n";
    printf STDOUT ("\t%5d  %10.3f\n", $itemqty, $itemamt);
    Add:
    Code:
    $totalqty += $itemqty;
    $totalamt += $itemamt;
    I love this script.

    Also, I like to keep track of buyers moreso than items (I seem to sell things quicker when I can send a tell to a frequent buyer letting them know that I have restocked. )... so, I updated the script accordingly:

    Code:
    #!/usr/local/bin/perl
    
    %coin2ix = (qw/p 0 g 2 s 3 c 4/);
    %soldamt = ();
    %soldqty = ();
    
    $soldre = '\[
    	[A-Z][a-z][a-z]		# Day abbreviation
    	\s
    	[A-Z][a-z][a-z]		# Month abbreviation
    	\s
    	\d\d			# Day number
    	\s
    	\d\d:\d\d:\d\d		# Time
    	\s
    	\d\d\d\d		# Year
    	\]
    	\s
    	(.*)			# Buyer
    	\spurchased\s
    	(\d+)			# Quantity
    	\s
    	(.*)			# Item
    	\sfor\s\(\s
    	(.*)			# Price
    	\)\.';
    
    while (<>) {
    	chomp;
    	if ($_ =~ /$soldre/x) {
    		$buyer = $1;
    		$qty = $2;
    		$itemname = $3;
    		$price = $4;
    		$amt = long_price_2_short_price($price);
    		$soldkey = join("\t", $buyer, $itemname);
    		$soldqty{$soldkey} += $qty;
    		$soldamt{$soldkey} += $amt;
    	}
    }
    
    $totalamt  = 0; 
    $totalqty  = 0;
    $itemamt   = 0; 
    $itemqty   = 0;
    $fencepost = 0;
    $currbuyer  = "";
    foreach $soldkey (sort {$a cmp $b} keys %soldqty) {
    	($buyer, $itemname) = split("\t", $soldkey);
    	if ($buyer ne $currbuyer) {
    		if ($fencepost) {
    			print STDOUT "\t-----  ----------\n";
    			printf STDOUT ("\t%5d  %10.3f\n", $itemqty, $itemamt);
    			$totalqty += $itemqty;
    			$totalamt += $itemamt;
    			$itemqty = 0;
    			$itemamt = 0;
    			$fencepost = 0;
    			print STDOUT "\n";
    		}
    		print STDOUT ($buyer, "\n\n");
    		print STDOUT "\t Qty     Amount    Item\n";
    		print STDOUT "\t-----  ----------  ------------------------\n";
    		$currbuyer = $buyer;
    	}
    	$fencepost = 1;
    	printf STDOUT ("\t%5d  %10.3f  %s\n",
    	$soldqty{$soldkey}, $soldamt{$soldkey}, $itemname);
    	$itemqty += $soldqty{$soldkey};
    	$itemamt += $soldamt{$soldkey};
    }
    
    # Print total for last item.
    print STDOUT "\t-----  ----------\n";
    printf STDOUT ("\t%5d  %10.3f\n", $itemqty, $itemamt);
    $totalqty += $itemqty;
    $totalamt += $itemamt;
    
    # Print total for all items.
    print STDOUT "\nGrand Total\n\n";
    print STDOUT "\t Qty     Amount    \n";
    print STDOUT "\t-----  ----------\n";
    printf STDOUT ("\t%5d  %10.3f\n", $totalqty, $totalamt);
    
    sub long_price_2_short_price {
    	my $name;
    	my $value;
    	my $price = shift;
    	my @fields = split(' ', $price);
    	my $count = scalar @fields;
    	if ($count < 1 or $count > 4) {
    		print STDERR "Something is wrong with the price field: $price\n";
    		exit(-1);
    	}
    	@cointab = (0, ".", 0, 0, 0);
    	foreach (@fields) {
    		($value, $name) = /(\d+)([pgsc])/;
    		$cointab[$coin2ix{$name}] = $value;
    	}
    	return join('', @cointab);
    }
    Gangleri Deaesir <Para Praxis>

    Comment


    • #17
      This is something I have been loooking for... I would love to see something added.

      I want to know I have sold item x how many times? What was my High price? What was my Low price? What was my average price?

      Can any body add this this scirpt plzs?


      Originally posted by sansaan
      Just the slightest of bugs in eqbzrsold.pl:

      After:
      Code:
      # Print total for last item.
      print STDOUT "\t-----  ----------\n";
      printf STDOUT ("\t%5d  %10.3f\n", $itemqty, $itemamt);
      Add:
      Code:
      $totalqty += $itemqty;
      $totalamt += $itemamt;
      I love this script.

      Also, I like to keep track of buyers moreso than items (I seem to sell things quicker when I can send a tell to a frequent buyer letting them know that I have restocked. )... so, I updated the script accordingly:

      Code:
      #!/usr/local/bin/perl
      
      %coin2ix = (qw/p 0 g 2 s 3 c 4/);
      %soldamt = ();
      %soldqty = ();
      
      $soldre = '\[
      	[A-Z][a-z][a-z]		# Day abbreviation
      	\s
      	[A-Z][a-z][a-z]		# Month abbreviation
      	\s
      	\d\d			# Day number
      	\s
      	\d\d:\d\d:\d\d		# Time
      	\s
      	\d\d\d\d		# Year
      	\]
      	\s
      	(.*)			# Buyer
      	\spurchased\s
      	(\d+)			# Quantity
      	\s
      	(.*)			# Item
      	\sfor\s\(\s
      	(.*)			# Price
      	\)\.';
      
      while (<>) {
      	chomp;
      	if ($_ =~ /$soldre/x) {
      		$buyer = $1;
      		$qty = $2;
      		$itemname = $3;
      		$price = $4;
      		$amt = long_price_2_short_price($price);
      		$soldkey = join("\t", $buyer, $itemname);
      		$soldqty{$soldkey} += $qty;
      		$soldamt{$soldkey} += $amt;
      	}
      }
      
      $totalamt  = 0; 
      $totalqty  = 0;
      $itemamt   = 0; 
      $itemqty   = 0;
      $fencepost = 0;
      $currbuyer  = "";
      foreach $soldkey (sort {$a cmp $b} keys %soldqty) {
      	($buyer, $itemname) = split("\t", $soldkey);
      	if ($buyer ne $currbuyer) {
      		if ($fencepost) {
      			print STDOUT "\t-----  ----------\n";
      			printf STDOUT ("\t%5d  %10.3f\n", $itemqty, $itemamt);
      			$totalqty += $itemqty;
      			$totalamt += $itemamt;
      			$itemqty = 0;
      			$itemamt = 0;
      			$fencepost = 0;
      			print STDOUT "\n";
      		}
      		print STDOUT ($buyer, "\n\n");
      		print STDOUT "\t Qty     Amount    Item\n";
      		print STDOUT "\t-----  ----------  ------------------------\n";
      		$currbuyer = $buyer;
      	}
      	$fencepost = 1;
      	printf STDOUT ("\t%5d  %10.3f  %s\n",
      	$soldqty{$soldkey}, $soldamt{$soldkey}, $itemname);
      	$itemqty += $soldqty{$soldkey};
      	$itemamt += $soldamt{$soldkey};
      }
      
      # Print total for last item.
      print STDOUT "\t-----  ----------\n";
      printf STDOUT ("\t%5d  %10.3f\n", $itemqty, $itemamt);
      $totalqty += $itemqty;
      $totalamt += $itemamt;
      
      # Print total for all items.
      print STDOUT "\nGrand Total\n\n";
      print STDOUT "\t Qty     Amount    \n";
      print STDOUT "\t-----  ----------\n";
      printf STDOUT ("\t%5d  %10.3f\n", $totalqty, $totalamt);
      
      sub long_price_2_short_price {
      	my $name;
      	my $value;
      	my $price = shift;
      	my @fields = split(' ', $price);
      	my $count = scalar @fields;
      	if ($count < 1 or $count > 4) {
      		print STDERR "Something is wrong with the price field: $price\n";
      		exit(-1);
      	}
      	@cointab = (0, ".", 0, 0, 0);
      	foreach (@fields) {
      		($value, $name) = /(\d+)([pgsc])/;
      		$cointab[$coin2ix{$name}] = $value;
      	}
      	return join('', @cointab);
      }
      Brewing 250
      Fletching 199
      Baking 154
      Fishing 15
      Tailorying 15

      Comment


      • #18
        ok so all this looks and sounds great but one question.......how do i get it to work? only scripts i know how to use are for the acting classes

        Comment


        • #19
          Originally posted by YurienStonebow
          ok so all this looks and sounds great but one question.......how do i get it to work? only scripts i know how to use are for the acting classes

          Down load and install active perl you will not need to reboot I dont think.

          Copy all the text/code in on of them boxes and paste it into note pade.

          Save file as What ever you want to call it .pl exmapl mine I named LogPr.pl

          Copy that file to the folder where all your bazzar log files are.

          Open a dos prompt Start\Run cmd then press enter

          cange to the folder where your stuff is:
          cd \ <enter>
          cd c:\Progam Files\Sony\EverQuest\Logs

          this is where min is I THINK im not at home to check...

          any way from the comand prompt type

          perl <nameOfFileYouMade.pl> <logyou want to get data from>

          exmaple for me : perl LogP.pl tuneName_BazarLog.txt

          then it will spit the data out on your screen.
          Brewing 250
          Fletching 199
          Baking 154
          Fishing 15
          Tailorying 15

          Comment


          • #20
            Just for your interest:
            There's a way to add .pl files to the files executed as .exe or .com in the commandline. Unfortunately i don't remember how, but this should be in the Active Perl documentation.
            Silamael Darkomen
            Enchanter of the 70th rank
            Guild Council Member of Corona Mundi
            Solusek Ro

            Comment


            • #21
              Originally posted by Silamael
              Just for your interest:
              There's a way to add .pl files to the files executed as .exe or .com in the commandline. Unfortunately i don't remember how, but this should be in the Active Perl documentation.

              Yes there is... I took his code up there and added a few things ets.

              http://mboards.eqtraders.com/eq/show...189#post141189

              has the files.

              They are in .bat format. Just drag the log file you want to work with and drop it into the .bat file.

              enjoy
              Brewing 250
              Fletching 199
              Baking 154
              Fishing 15
              Tailorying 15

              Comment

              Working...
              X