chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix spelling error in intro
[ypp-sc-tools.db-live.git]
/
yarrg
/
commod-results-processor
diff --git
a/yarrg/commod-results-processor
b/yarrg/commod-results-processor
index 36804d35d64c34f25f07fbb22a0de06ad8ee9454..37484d6ef6ff071172036578b55a1eef3d2bb301 100755
(executable)
--- a/
yarrg/commod-results-processor
+++ b/
yarrg/commod-results-processor
@@
-51,6
+51,7
@@
sub bs_read ($$) {
return if @v <= $c;
my ($price,$qty) = @v[$c..$c+1];
return if !length($price) && !length($qty);
return if @v <= $c;
my ($price,$qty) = @v[$c..$c+1];
return if !length($price) && !length($qty);
+ die "$price ?" unless $price =~ m/^\d/;
die "$_ ?" unless length($price) && length($qty);
$commod{$commod}{$bs}{$stall}= {
Stall => $stall,
die "$_ ?" unless length($price) && length($qty);
$commod{$commod}{$bs}{$stall}= {
Stall => $stall,
@@
-63,6
+64,10
@@
while (<>) {
chomp;
@v= split /\t/;
#print STDERR "[".join("|",@v)."]\n";
chomp;
@v= split /\t/;
#print STDERR "[".join("|",@v)."]\n";
+ foreach (@v[2..$#v]) {
+ s/\,//g;
+ die "$_ ?" if m/.\D/;
+ }
($commod,$stall) = @v;
bs_read(Buy, 2);
bs_read(Sell, 4);
($commod,$stall) = @v;
bs_read(Buy, 2);
bs_read(Sell, 4);
@@
-204,8
+209,8
@@
sub bs_p_tsv ($$) {
}
}
}
}
-sub write_tsv ($) {
- my ($f) = @_;
+sub write_tsv ($
$
) {
+ my ($f
,$showhold
) = @_;
foreach $commod (sort keys %commod) {
$current= $commod{$commod};
my %stalls;
foreach $commod (sort keys %commod) {
$current= $commod{$commod};
my %stalls;
@@
-215,6
+220,9
@@
sub write_tsv ($) {
printf($f "%s\t%s", $commod, $stall) or die $!;
bs_p_tsv($f, Buy);
bs_p_tsv($f, Sell);
printf($f "%s\t%s", $commod, $stall) or die $!;
bs_p_tsv($f, Buy);
bs_p_tsv($f, Sell);
+ if ($showhold && $commod{$commod}{Hold}) {
+ printf($f "\t%s", $commod{$commod}{Hold}) or die $!;
+ }
print($f "\n") or die $!;
}
}
print($f "\n") or die $!;
}
}
@@
-223,7
+231,7
@@
sub write_tsv ($) {
}
sub main__tsv () {
}
sub main__tsv () {
- write_tsv(\*STDOUT);
+ write_tsv(\*STDOUT
,1
);
}
}
@@
-449,7
+457,7
@@
sub main__uploadyarrg () {
$o{'timestamp'}= $ENV{'YPPSC_DATA_TIMESTAMP'} or die;
my $tf= pipethrough_prep();
$o{'timestamp'}= $ENV{'YPPSC_DATA_TIMESTAMP'} or die;
my $tf= pipethrough_prep();
- write_tsv($tf);
+ write_tsv($tf
,0
);
my $oz= pipethrough_run_gzip($tf);
$o{'data'}= [ undef, 'deduped.tsv.gz',
Content_Type => 'application/octet-stream',
my $oz= pipethrough_run_gzip($tf);
$o{'data'}= [ undef, 'deduped.tsv.gz',
Content_Type => 'application/octet-stream',