rabobank internet bankieren mut.txt spaar rekening mutaties naar saldo grafiek parser in perl.
je moet wat, als je je verveelt. dus verveel je je ook, copy paste dan 't script van hieronder.
Verveel je je niet, dan
klik je hier om um te downloaden.
#!/usr/bin/perl -w
# (C) 2003 S. Smeenk.
# GNU Pubic License version 2 code. Please obey :)
#
use strict;
use GD::Graph::bars;
use Data::Dumper;
$Data::Dumper::Indent = 0;
#### Config :)
my $rekeningno = "0123456789"; # Must match ^"$rekeningno" in mut.txt
my $graphfile = "./saldo.png";
my $debug = 1;
#### Internal :)
if (!$ARGV[0] || ($ARGV[0] !~ /^\d+.\d{2}$/)) {
die "Type of arg 1 to $0 should be floating point like '1234.56' or '0.00'\n";
}
my $startsaldo = $ARGV[0];
my (@lines, $saldohash);
#### Import saved 'history'
if (open (FD, "mut.dat")) {
print "History read from mut.dat\n" if ($debug);
local $/ = undef; my $blob = <FD>; $saldohash = eval 'my ' . $blob;
close(FD);
} else {
print "No mut.dat -> no history yet\n" if ($debug);
}
#### Import mut.txt
open (FD, "mut.txt") or die "Kan mut.txt niet openen? ($!)\n";
while (<FD>) { next if ($_ !~ /^"$rekeningno"/); chomp; push @lines, $_; } close(FD);
#### Process mut.txt lines in reverse order as to calculate
#### what the saldo was on the first known date.
foreach (reverse @lines) {
my ($ownrek, $valuta, $date, $direction, $amount) = split /"?,"?/;
if ($direction eq "C") {
print "-" if ($debug);
$startsaldo -= $amount;
} elsif ($direction eq "D") {
print "+" if ($debug);
$startsaldo += $amount;
}
$$saldohash{$date} = $startsaldo;
}
print "\nNumber processed: ".scalar(@lines)."\n" if ($debug);
#### Save saldo history
open (FD, ">mut.dat") or die "Can't write to mut.dat? ($!)\n";
print FD Dumper($saldohash); close(FD);
print "History saved in mut.dat\n" if ($debug);
#### array building
my @graph_array = ( [], [] );
foreach my $key (sort keys %$saldohash) {
push @{$graph_array[0]}, $key;
push @{$graph_array[1]}, $$saldohash{$key};
}
#### GD object, and options.
my $graph = GD::Graph::bars->new(1024, 768);
$graph->set(
x_label => 'Datum',
y_label => 'Saldo',
title => "Saldografiek voor $rekeningno",
accentclr => "#ff0000", #
boxclr => undef,
bar_spacing => 1,
transparent => undef,
interlaced => undef,
x_label_skip => 7,
y_tick_number => 16,
y_label_skip => 0,
) or die $graph->error;
#my $gd = $graph->plot(\@graph_array) or die $graph->error;
open (IMG, ">$graphfile") or die "Can't write $graphfile? ($!)\n";
binmode(IMG);
print IMG $graph->plot(\@graph_array)->png;
close(IMG);
print "Donet!\n" if ($debug);