Chore App

I made this chore asigning application for a small college dorm. Its purpose is to randomly assign chores to residents with respect to gender. A male (m) will get a male chore or gender neutral chore (n) and female (f) will get a female chore or gender neutral chore. Note random is not fair. Good Luck

The files needed

  • list of residents
   gender firstname lastname
   m john smith
   f julie smith
   m tom appleseed
  • list of chores
  gender chore
  f clean womens bathroom
  n mop hallway
  m clean mens showers

  • clean.icns - an icon file

Build the App

Setup Python Virtaul Environment

pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install xlwt py2app

Chore App Code

Please place chore app code in a seperate directory differnet to the python virtual environment.

import os, sys,random, xlwt, time, datetime
from xlwt import *

#file imports
chore_file=open("../../../chores.txt", "r")
chores = chore_file.readlines()
#print chores

resident_file=open("../../../residents.txt", "r")
residents = resident_file.readlines()
#print residents

#create a psueode final enum
# m equals male
# f equals female
# n equals neutral

#creates excel file
book = xlwt.Workbook(encoding="utf-8")
sheet1 = book.add_sheet("Sheet 1")

font0 = Font()
font0.bold = True

style0 = XFStyle()
style0.font = font0

#error check
if len(chores) != len(residents):
    print "Error:"
    if len(chores) > len(residents):
            sys.exit(" Too many chores")
            sys.exit(" Too many residents")

assignment = []
i = 0
    rand = random.randrange(0, len(residents))

    # retrieves the f or m before residents name
    resident = residents[rand]
    resident_gender = resident[0:1]
    chore_gender = chores[i][0:1]

    if(resident_gender == chore_gender) or (chore_gender == 'n'):
        len_chore = len(chores[i])
        len_resident = len(resident)
        print resident[2:len_resident] + " "  + chores[i][2:len_chore]
        tupl = [resident[2:len_resident].replace('\n',''), chores[i][2:len_chore].replace('\n','')]

#alphabetically sort
#write out alphabetically sorted chore list
date =
enddate = + datetime.timedelta(days=6)
sheet1.write(0,0,"Chore List For Week Of " + date.strftime('%m/%d') +" - "+ enddate.strftime('%m/%d'), style0)
for i in assignment:

#saves excell file"../../../chores"+ date.strftime('%Y_%m_%d') + ".xls")"chores"+ date.strftime('%Y_%m_%d') + ".xls")

The Build

Change the the working direcotry to the chore_app and create a file called

cd chore_app
   This is a script generated by py2applet

   python py2app
   from setuptools import setup

   APP = ['']
   DATA_FILES = ['chores.txt','residents.txt']
   OPTIONS = {
    'argv_emulation': True,
    'iconfile': 'clean.icns',
    'plist': {
        'CFBundleName': "ChoreApp",
        'CFBundleDisplayName': "ChoreApp",
        'CFBundleGetInfoString': "App for assigning chore",
        'CFBundleVersion': "0.2.0",
        'CFBundleShortVersionString': "0.2.0",
        'NSHumanReadableCopyright': u"Copyleft Devon Peel"

    options={'py2app': OPTIONS},

Time to build the App

python py2app

Run ChoreApp

Place the ChoreApp file created in the above command with the chores.txt file and residents.txt file in the same directory. Then click on the ChoreApp to generate the output file assigning chores to residents.