Thread Datenblöcke mitteln (8 answers)
Opened by EagleFox at 2006-07-25 14:04

Ronnie
 2006-07-26 03:10
#68380 #68380
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
Ich habe mal angenommen das die erste Spalte eine fortlaufenden steigende Nummer ist, aber so sollte es funktionieren:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

use strict;
use warnings;

my %set;
my $set_cnt = 1;
my $line_cnt = 0;

while (<DATA>) {
chomp;

++$line_cnt and next if /^\s*$/;
if ($line_cnt == 2) { $line_cnt = 0; $set_cnt++ }

my ($n, @m) = split /\s+/;
$set{$n}->[$_] += $m[$_] for 0 .. $#m;
}

foreach my $k (sort { $a <=> $b } keys %set) {
print $k, "\t";
print $_/$set_cnt, "\t" for @{$set{$k}};
print "\n";
}


__DATA__
90 0.0247481564832794 0.672855350654247
91 0.0179393727770228 0.681444966159488
92 0.0304371590737797 0.691292629756847
93 0.0262014613090327 0.707479206603499
94 0.0305333702130782 0.724031300019831
95 0.0525632991251114 0.753174235934156


90 0.0230764579156433 0.676198398681967
91 0.0282334103527949 0.684963109911959
92 0.0275317795328473 0.694989480270408
93 0.0301524562700934 0.70796497660355
94 0.037567005927381 0.729267549176281
95 0.0572362219534508 0.763883493442457
\n\n

<!--EDIT|Ronnie|1153869110-->

View full thread Datenblöcke mitteln