Skip to content

Instantly share code, notes, and snippets.

@rm77
Created August 2, 2021 05:09
Show Gist options
  • Save rm77/967cbc9acd7ec87ece9561582658b316 to your computer and use it in GitHub Desktop.
Save rm77/967cbc9acd7ec87ece9561582658b316 to your computer and use it in GitHub Desktop.
hitung jumlah chat wa, downloadlah wa history ke nama file file.txt, dan jalankan python3 hitungwa.py
from datetime import datetime
import re
#datetime.strptime(h[0],'%m/%d/%y, %I:%M %p')
f = open('file.txt','r')
hasil = f.readlines()
ss = dict()
for i in hasil:
h = i.split('-',1)
waktu = h[0]
try:
jj = h[1].split(':',1)
if (len(jj)==2):
try:
datetime.strptime(waktu.strip(),'%m/%d/%y, %I:%M %p')
#print(waktu,jj,len(jj))
nama = jj[0]
if (nama in ss):
ss[nama]=ss[nama]+1
else:
ss[nama]=0
except ValueError as ve:
pass
except IndexError as es:
pass
ii = sorted(ss.items(), key=lambda x: x[1], reverse=True)
for xx in ii:
nama,jumlah = xx
if (jumlah>0):
print(f"{nama} : {jumlah}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment