Skip to content

Instantly share code, notes, and snippets.

Last active August 1, 2019 15:58
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save svandragt/080843c4ba632deaab6f3aea57ca9684 to your computer and use it in GitHub Desktop.
WorkLogPy: Keep track of what you are working on (Python 3). Writes a timestamped message to a CSV file.
#!/usr/bin/env python3
from random import choice
from datetime import datetime
def wlog(answer,now):
with open(f"worklog-{now:%Y%m%d}.csv", "a") as f:
def main():
wlog('--start session--', )
while True:
answer = input("Working on: ")
if answer.strip() == '':
now =
wlog(answer, now )
print(f"[{now:%a %H:%M}] ✓")
except EOFError:
wlog('--stop session--', now )
if __name__== "__main__":
Copy link

v1.0.3: only keep the file open to write, so that changes are always saved. Previous versions would keep the log open when the script was running, preventing dropbox syncing.

Copy link

svandragt commented Aug 1, 2019

v2.2: ctrl-d or enter to quit. works on python2 default systems. f-strings, code more elegant. day based csv files.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment