Thursday, February 7, 2019

Generate Report on Active Users in WhatsApp Group

Sometimes you feel lots of messaging is happening in your WhatsApp.

Targeted Audience for this report: Folks familiar with Unix shell programming/Usage

In case you want to find the most active user in a WhatsApp group on per day basis. Here is one crude way to get such report:
  • Export the WhatsApp chat messages to your email/storage (let us say you stored it as what1.txt )
  • Transfer that file to your deskstop where you have Unix-Shell utilities (like bash, tr, awk, sed, perl, grep , sort, uniq)
  • Run following shell script on the above what1.txt file

grep "/19" what1.txt |
    sed -e 's/, .* .m - / /g;s/:.*$//g'|
    perl -i -pe 's#(\d*)/(\d*)/(\d*) #$2/$1/$3 #g' |
    grep -vE "/18"|
    sort |
    uniq -c |
    tr '/' ' '|
    gawk '{ if (old != ($2*100+$3))
                {print "\n" $2 "-" $3 "-" $4 "\n";};
            old=($2*100+$3);
            if ( $1 > 3 )
                {print $1 , $5,$6,$7,$8 }}' 


    •  Notes:
      • "/19"  : filtering of the year of chats
      • sed -e 's/, .* .m - / /g;s/:.*$//g' : Remove unwanted message parts
      •  perl -i -pe 's#(\d*)/(\d*)/(\d*) #$2/$1/$3 #g' :  change order of day/month/year to month/day/year format
      • gawk script to find out
        • active users whose posts > 3 ( $1 > 3)
        • Print headings for day basis
          •  if (old != ($2*100+$3))
                            {print "\n" $2 "-" $3 "-" $4 "\n";};
        • Print message count per user
          •  {print $1 , $5,$6,$7,$8 }}