Skip to content

Instantly share code, notes, and snippets.



Last active Jan 1, 2019
What would you like to do?
Pythonista compatible python script for keeping track of and visualizing your numerical answer to daily questions.

Daily Tracker

How to Install

This script is intended to run in Pythonista on iOS. It works equally well on desktop OSs. Installation instructions will be solely for Pythonista.

  1. Copy the contents of this
  2. Open a new file in Pythonista called and paste the contents.
  3. Click the wrench icon.
  4. Click Home Screen
  5. Choose your own Title, Icon, Background Color, but keep it on Run Script
  6. This opens a new tab in Safari. Click the Share icon and click Add to Home Screen.
  7. Follow steps to add to home screen.
  8. Done!


The app provides statements describing most of the functionality provided.

import numpy as np
import json
from matplotlib import pyplot as plt
from os import path
from datetime import datetime, timedelta
consts = {
1: 2,
2: 7,
3: 30,
4: 365,
5: 1000
def set_questions():
Writes input text to a file `questions.txt`, separated by a new line.
This will represent the questions to be asked
print("Please enter each of your questions separated by a new line, enter just 'q' to finish")
with open('./questions.txt', 'w') as f:
while 1:
question = input()
if question is 'q':
with open('./data.json', 'w') as f:
def enter_scores(check):
For every question in questions.txt, ask for an integer value and add to data.json
:return: dictionary of questions to list of responses
if check:
if ( - timedelta(1)).strftime("%d%m%y") != datetime.fromtimestamp(
print("Whoops, you tried to enter a value twice in one day!")
print("Please enter your scores for today")
with open("./data.json", 'r') as f:
# Define 10 questions within the triple quotes separated by a new line
questions = []
with open('./questions.txt', 'r') as qs:
questions ='\n')
kv = json.load(f)
for line in questions:
if line is not '':
answer = int(input(line))
while answer < 0 or answer > 10:
print("Please enter a number between 0-10")
answer = int(input(line))
if line not in kv:
kv[line] = [answer]
with open('./data.json', 'w') as f:
json.dump(kv, f)
print("Awesome! Thanks for adding your scores today")
return kv
def show_graph(freq, kv):
Given a dictionary of questions and frequency, output a matplotlib graph of all questions
:param freq: Number of data points to show
:param kv: dictionary of questions to list of answers
lst = []
ln = 0
for key in kv.keys():
if freq != 1000:
ln = len(kv[key][:freq])
mx = len(kv[key][:freq])
rng = range(0, len(kv[key][:freq]))
most = list(reversed(kv[key][:freq]))
ln = len(kv[key])
rng = range(0, len(kv[key]))
mx = len(kv[key])
most = list(reversed(kv[key]))
for i in rng:
lst.append(( - timedelta(days=i)).strftime('%b, %d %Y'))
x = np.arange(0, mx)
y = np.array(most)
plt.plot(x, y, label=key.replace("?", ""))
plt.xticks(range(0, ln), list(reversed(lst)), rotation=45)
should_save = input("Would you like to save this graph?\n1) yes\n2) no\n")
if should_save is '1':
if __name__ == '__main__':
print("Welcome! This is a program to help keep track of and visualize things you find important"
" everyday")
yes = False
while 1:
print("Is this your first time?\n1) yes\n2) no")
is_first = input()
if int(is_first):
if int(is_first) == 1:
yes = True
print("Please enter 1 or 0")
kv = enter_scores(yes)
while 1:
print("How would you like to see this data?\n"
"1) Past 2 Days\n"
"2) This Week\n"
"3) This Month\n"
"4) This Year\n"
"5) All Time")
freq = input()
if int(freq):
show_graph(consts[int(freq)], kv)
print("Please enter 1 or 0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment