Skip to content

Instantly share code, notes, and snippets.

@joejag
Created January 12, 2023 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joejag/a918353618a6d60d36427b3d726f128b to your computer and use it in GitHub Desktop.
Save joejag/a918353618a6d60d36427b3d726f128b to your computer and use it in GitHub Desktop.
import datetime as DT
from itertools import cycle
import csv
rota = cycle(
[
"Brown",
"Blue",
"Green + Brown",
"Blue",
"Brown",
"Green + Blue",
]
)
with open("bins.csv", "w") as file:
fieldnames = ["Subject", "Start date"]
writer = csv.DictWriter(file, fieldnames=fieldnames)
writer.writeheader()
for week in range(0, 52):
pickup_day = DT.date(2023, 1, 6) + DT.timedelta(days=7 * week)
bin = next(rota)
writer.writerow({"Subject": f"{bin} bin day", "Start date": pickup_day})
for pickup_number in range(0, 6):
pickup_day = DT.date(2023, 2, 22) + DT.timedelta(days=7 * pickup_number * 8)
writer.writerow({"Subject": "Purple bin day", "Start date": pickup_day})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment