Dear Monks,
I have used a hash table with several values for the same key but I would like to display the results in a slightly different way my program currently gives. Could you check this ? Thanks a lot
Here are the results
Here what I would likeEG2;100;22/10/2006;0.185416666666667;04:21:45;C; EDD;100;22/10/2006;0.207428571428572;02:30:02;W; 04:00:00;W; EGC;80;22/10/2006;0.284926470588235;05:58:56;S;
EG2;100;22/10/2006;0.185416666666667;04:21:45;C; EDD;100;22/10/2006;0.207428571428572;02:30:02;W; ;;;;04:00:00;W; EGC;80;22/10/2006;0.284926470588235;05:58:56;S;
Here is my program (tested with $week = W42)
my $KPIs_fa_infile = "KPIs_fa_TACT_${week}.csv"; open my $KPIs_fa_INFILE, q{<}, $KPIs_fa_infile or die; my $capa_fa_infile = "all_capa_fa_${week}.csv"; open my $capa_fa_INFILE, q{<}, $capa_fa_infile or die; my $KPIs_fa_outfile_with_capa_infos = "KPIs_fa_TACT_${week}_capa.csv"; open my $KPIs_fa_OUTFILE_capa, q{>}, $KPIs_fa_outfile_with_capa_infos +or die; my %KPI; while(my $line = <$KPIs_fa_INFILE>){ $line =~ s/\s+$//; my @Elements = split /;/, $line; # on enlève le premier element my $reg = shift(@Elements); $KPI{$reg}= join ";", @Elements; } close $KPIs_fa_INFILE; my %capa; while(my $line = <$capa_fa_INFILE>){ $line =~ s/\s+$//; my @Elements = split /;/, $line; # on enlève le premier element my $reg = shift(@Elements); my $value = join ";", @Elements; $value = "$value;"; #print STDOUT "the value is $value\n"; push( @{$capa{$reg}}, $value ); } close $capa_fa_INFILE; my @KEYS = keys %KPI; my $key; foreach $key(@KEYS){ if (exists $capa{$key}){ #print $KPIs_fa_OUTFILE_capa $KPI{$key} $capa{$key}; print $KPIs_fa_OUTFILE_capa "$key;$KPI{$key};@{$capa{$key}}\n"; } } close $KPIs_fa_OUTFILE_capa;
Here is KPIs_fa_TACT_W42.csv
EDD;100;22/10/2006;0.207428571428572 EKR;80;22/10/2006;0.0956081081081081 EG2;100;22/10/2006;0.185416666666667 LFP;100;22/10/2006;0.330322580645161 EGC;80;22/10/2006;0.284926470588235
Here is all_capa_fa_W42.csv
E2F;07:51:21;T EDD;02:30:02;W EDD;04:00:00;W EG1;10:24:42;C EG2;04:21:45;C EGC;05:58:56;S
In reply to display correction by steph_bow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |