open(my $out_fh, '>', $out_file);
foreach my $val ( 1 .. 4 ) {
print $out_fh join(',', map { $_ . '_' . $val } @{ $data_headers[$val] });
- print $out_fh ',' if $val < 4;
+ print $out_fh ',';
}
+print $out_fh "broj_valova";
print $out_fh "\n";
foreach my $key ( sort keys %$data ) {
print " $key";
foreach my $id ( sort keys %{ $data->{$key} } ) {
#print $out_fh "## $id ## ";
+
+ my $broj_valova = 0;
+
foreach my $val ( 1 .. 4 ) {
if ( my $id_data = $data->{$key}->{$id}->{$val} ) {
print $out_fh join(',', @$id_data);
+ $broj_valova++;
} else {
print $out_fh ( ',' x $#{ $data_headers[$val] } ) ; # FIXME +1?
}
- print $out_fh ',' if $val < 4;
+ print $out_fh ',';
}
+ print $out_fh $broj_valova;
print $out_fh "\n";
}
}