Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use Text::CSV;
- use POSIX qw(strftime);
- use Data::Dumper;
- use LWP::Simple;
- my $APK_GCM="/root/Basavaraj/GCM/cdr_02-01-2018_StreamzGcm.csv";
- my $WEB_GCM="/root/Basavaraj/GCM/cdr_02-01-2018_StreamzWebPushNotification.csv";
- my $Yesterday= strftime ("%d-%m-%Y", localtime(time-86400));
- my $Current_Date= strftime ("%d-%m-%Y",localtime(time));
- print "$Yesterday n";
- print "$Current_Date n";
- open(STDOUT, '>', "/root/Basavaraj/STREAMZ_GCM_APK.txt");
- #Creating Class to split the document line by line by comma ,
- my $csv = Text::CSV->new({ sep_char => ',' });
- open (my $data, '<:encoding(utf8)', $APK_GCM) or die "Could Not open File '$APK_GCM' $!n";
- open (my $data1,'<:encoding(utf8)', $WEB_GCM) or die "Could Not open File '$WEB_GCM' $!n";
- my %mapA;
- my $dummyA =<$data>;
- while (my $line = <$data>) {
- if ($csv->parse($line)) {
- my @fields = $csv->fields();
- my $Brand_Name=$fields[2];
- my $Streamz_Sent=$fields[5];
- my $GoogleResA=$fields[5];
- $mapA{$Brand_Name} = {Success =>0,Failure=> 0} unless exists ($mapA{$Brand_Name});
- my $failureA='{error:MismatchSenderId}';
- if ($GoogleResA eq $failureA){
- $mapA{$Brand_Name}->{Failure}++;
- print "$Brand_Name:$mapA{$Brand_Name}->{Failure} n";
- }else{
- $mapA{$Brand_Name}->{Success}++;
- print "$Brand_Name:$mapA{$Brand_Name}->{Success} n";
- }
- } else {
- warn "Line could not be parsed: $linen";
- }
- }
- #$, = ",";
- print " $mapA{$Brand_Name}->{Failure} n";
- my $KeyA;
- while (($keyA)=each (%mapA)){
- my $success= $mapA{$Brand_Name}->{Success};
- my $failure= $mapA{$Brand_Name}->{Failure};
- print "$keyA $mapA{$Brand_Name}->{Failure}++ $mapA{$Brand_Name}->{Success}++ n";
- }
- foreach my $name ( keys %mapA) {
- print " $mapA{$Brand_Name}->{Failure} n";
- print " $mapA{$Brand_Name}->{Success} n";
- print "$name $mapA{$Brand_Name}->{Success} $mapA{$Brand_Name}->{Failure} n";
- }
Add Comment
Please, Sign In to add comment