-
Notifications
You must be signed in to change notification settings - Fork 0
/
collate-results.pl
50 lines (36 loc) · 972 Bytes
/
collate-results.pl
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
42
43
44
45
46
47
48
49
50
#!/bin/perl
use warnings;
use strict;
use File::Find;
my @files;
sub wanted {
if (/\.csv$/) {
my $name = $File::Find::name;
$name =~ s/^\.\/results\/|\.csv$//g;
push @files, $name;
}
}
find(\&wanted, "./results");
my @csv;
my @header = ("System", "Mutation", "Crossover", "Problem", "Run");
use Tie::File;
tie my @headerCSV, "Tie::File", "./results/$files[0].csv";
push @header, split(/,/, $headerCSV[0]);
push @csv, \@header;
foreach my $i (0..$#files) {
$files[$i] =~ /([^\/]+)\/([^\/]+)\/([^\/]+)\/([^\/]+)\/best-fitnesses-run-(\d+)/;
my $system = $1;
my $mutation = $2;
my $crossover = $3;
my $problem = $4;
my $run = $5;
my @row = ($system, $mutation, $crossover, $problem, $run);
tie my @resultCSV, "Tie::File", "./results/$files[$i].csv";
push @row, split(/,/, $resultCSV[1]);
push @csv, \@row;
}
open (my $csvOutput, '>', "results.csv");
foreach my $i (0..$#csv) {
print $csvOutput join(",", @{$csv[$i]})."\n";
}
close $csvOutput;