Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.79 KB | None | 0 0
  1. open FH, "results.tsv";
  2. @lines = <FH>;
  3. close FH;
  4.  
  5.  
  6. for $line (@lines) {
  7.     @info = split/\t/, $line;
  8.     $ids{$info[7]} = $info[6];
  9.     if ($info[0] =~ /(\d\d\d\d)$/) {
  10.         $year = $1;
  11.         if ($last{$info[7]} ne $info[0]) {
  12.             $all{$info[7]}++;
  13.             $comps{$year}{$info[7]}++;
  14.             $last{$info[7]} = $info[0];
  15.         }
  16.     }
  17.    
  18. }
  19. open FH, ">output.txt";
  20.  
  21. print FH "\n\nAll\n\n";
  22. %y = %all;
  23. &prtsorted;
  24.  
  25. for $year (reverse(2003..2010)) {
  26.     print FH "\n\n".$year."\n\n";
  27.     %y = %{$comps{$year}};
  28.     &prtsorted;
  29. }
  30.  
  31. close FH;
  32.  
  33. sub prtsorted {
  34.     $i = 1;
  35.     $nu = 0;
  36.     $pre = 0;
  37.     foreach $id (sort {$y{$b} <=> $y{$a}} keys %y) {
  38.         if ($i <= 500 || $pre == $y{$id}) {
  39.             if ($pre == $y{$id}) {
  40.                 $nu++;
  41.             } else {
  42.                 $nu = 0;
  43.             }
  44.             print FH $i-$nu.". ".$ids{$id}." ".$y{$id}."\n";
  45.            
  46.             $pre = $y{$id};
  47.             $i++;
  48.         } else {
  49.             last;
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement