Created
August 2, 2021 05:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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