Guest User

Untitled

a guest
Jan 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use Text::CSV;
  4. use POSIX qw(strftime);
  5. use Data::Dumper;
  6. use LWP::Simple;
  7.  
  8. my $APK_GCM="/root/Basavaraj/GCM/cdr_02-01-2018_StreamzGcm.csv";
  9. my $WEB_GCM="/root/Basavaraj/GCM/cdr_02-01-2018_StreamzWebPushNotification.csv";
  10.  
  11. my $Yesterday= strftime ("%d-%m-%Y", localtime(time-86400));
  12. my $Current_Date= strftime ("%d-%m-%Y",localtime(time));
  13.  
  14. print "$Yesterday n";
  15. print "$Current_Date n";
  16.  
  17. open(STDOUT, '>', "/root/Basavaraj/STREAMZ_GCM_APK.txt");
  18. #Creating Class to split the document line by line by comma ,
  19. my $csv = Text::CSV->new({ sep_char => ',' });
  20.  
  21. open (my $data, '<:encoding(utf8)', $APK_GCM) or die "Could Not open File '$APK_GCM' $!n";
  22. open (my $data1,'<:encoding(utf8)', $WEB_GCM) or die "Could Not open File '$WEB_GCM' $!n";
  23.  
  24. my %mapA;
  25. my $dummyA =<$data>;
  26. while (my $line = <$data>) {
  27. if ($csv->parse($line)) {
  28. my @fields = $csv->fields();
  29. my $Brand_Name=$fields[2];
  30. my $Streamz_Sent=$fields[5];
  31. my $GoogleResA=$fields[5];
  32. $mapA{$Brand_Name} = {Success =>0,Failure=> 0} unless exists ($mapA{$Brand_Name});
  33. my $failureA='{error:MismatchSenderId}';
  34. if ($GoogleResA eq $failureA){
  35. $mapA{$Brand_Name}->{Failure}++;
  36. print "$Brand_Name:$mapA{$Brand_Name}->{Failure} n";
  37. }else{
  38. $mapA{$Brand_Name}->{Success}++;
  39. print "$Brand_Name:$mapA{$Brand_Name}->{Success} n";
  40. }
  41.  
  42. } else {
  43. warn "Line could not be parsed: $linen";
  44. }
  45. }
  46. #$, = ",";
  47. print " $mapA{$Brand_Name}->{Failure} n";
  48. my $KeyA;
  49. while (($keyA)=each (%mapA)){
  50. my $success= $mapA{$Brand_Name}->{Success};
  51. my $failure= $mapA{$Brand_Name}->{Failure};
  52. print "$keyA $mapA{$Brand_Name}->{Failure}++ $mapA{$Brand_Name}->{Success}++ n";
  53. }
  54. foreach my $name ( keys %mapA) {
  55. print " $mapA{$Brand_Name}->{Failure} n";
  56. print " $mapA{$Brand_Name}->{Success} n";
  57. print "$name $mapA{$Brand_Name}->{Success} $mapA{$Brand_Name}->{Failure} n";
  58. }
Add Comment
Please, Sign In to add comment