Created
December 7, 2017 02:54
-
-
Save markwk/7c8e3debba11f250c18f3e9b99e4fd4a to your computer and use it in GitHub Desktop.
Scripts for Stats from WordCounter App for Mac
This file contains hidden or 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
# Python Script for Word Counter for Mac | |
# Collects Daily Score | |
import plistlib | |
import os | |
import time | |
def add(x, y): return x + y | |
today = time.strftime("%Y-%m-%d") | |
# read PLIST | |
records = os.path.expanduser('~/Library/Application Support/WordCounter/app_records.plist') | |
data = plistlib.readPlist(records) | |
# collect per-app totals | |
apps = data[today] | |
counts = [] | |
for app in apps: | |
count = reduce(add, app["counts"]) | |
counts.append(count) | |
print app["id"] + ": " + str(count) | |
total = reduce(add, counts) | |
print total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment