merge_csv.pl - Added an optional post-build rnd zip argument which adds a timestamp field to the CSV. Requires '7z' not '7za'.
authorMatt Davies <mattd@symbian.org>
Fri, 29 May 2009 14:45:54 +0100
changeset 121 fc757bffbe1d
parent 101 71122b8e1c7b
child 122 5639fead6fba
merge_csv.pl - Added an optional post-build rnd zip argument which adds a timestamp field to the CSV. Requires '7z' not '7za'.
common/tools/analysis/merge_csv.pl
--- a/common/tools/analysis/merge_csv.pl	Tue May 19 16:12:17 2009 +0100
+++ b/common/tools/analysis/merge_csv.pl	Fri May 29 14:45:54 2009 +0100
@@ -17,7 +17,7 @@
 use strict;
 my $csvfile = shift @ARGV;
 my $filelist = shift @ARGV;
-
+my $zipfile = shift @ARGV;
 
 if(! -e $csvfile)
 {
@@ -29,7 +29,28 @@
 {
   die "Cannot find $filelist\n";
 }
+        my %ziptimes;
+        if(defined $zipfile)
+          {
+          open(ZIP,"7z l $zipfile 2>&1|")  or die "Error: Couldn't look in $zipfile\n";
+#          print "time,file\n";
+          while( my $line = <ZIP>)
+            {
+            if($line =~ m/^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s\S{5}\s+(\d+)\s+\d+\s+(.+)$/) #ignoring packed size...
+              {
+              my $name = $3;
+              my $size = $2;
+              my $time = $1;
+              $name =~ s/\\/\//g;
+              $name = lc($name);
+              $ziptimes{$name} = $time;
+#              print "$time,$name\n";
+              }
+            }
+          close ZIP;
+          }
         my %files;
+
         open(FILES,"<$filelist") or die "Couldn't open $filelist\n";
         while(my $line = <FILES>)
         {
@@ -44,7 +65,7 @@
                 if($files{$file})
                 {
            
-                    $files{$file} = $files{$file}.",".$group;                                        
+                    $files{$file} = $files{$file}." ".$group; #Stop polluting next column                                        
                        print "Multi:$file".$files{$file}."\n";
 
                 }
@@ -61,7 +82,7 @@
         open(RESULTS,">$resultsfile") or die "Couldn't open write to $resultsfile\n";
         my $header = <CSV>;
         $header =~ s/\n//;
-        print RESULTS $header.",status\n";
+        print RESULTS $header.",status,time\n";
         my @fields = split(',',$header);
         my $targetindex = 0;
         my $counter = 0;
@@ -93,9 +114,10 @@
             {
               $bldinffiles{$bldinf} = 1;
             }
- 
+            my $found = 0; 
             if(defined $files{$target})
-                {                    
+                {
+                    $found = 1;                    
                     $line = $line.$files{$target};
                     if($files{$target} =~ m/fail/i)
                     {
@@ -105,6 +127,17 @@
                       }
                     }
                 }
+            if(defined $ziptimes{$target})
+              {
+                if($found)
+                {
+                  $line = $line.",".$ziptimes{$target};
+                }
+                else
+                {
+                  $line = $line.",,".$ziptimes{$target};
+                }
+              }     
             print RESULTS $line."\n";
             
             }