not exported
Day Date
1 15/5/2023
2 16/5/2023
3 17/5/2023
4 18/5/2023
Slot Timings
1 09:00–10:30
2 10:45–12:15
3 13:00–15:30
4 15:45–17:00
Day Slot Row Title
1 1 1 Introduction
1 2 2 Style
1 3 3 Maths / Algorithms / Plots
1 4 4 Ethics / Writing Exercise (AH/JB)
2 1 5 Literature review
2 2 6 Editing / Proofreading
2 3 7 Proofreading Exercise
2 4 8 OSR / Impact (EG)
3 1 9 Data analysis (SS)
3 2 10 Presenting
3 3 11 Seminar (2pm)
3 4 12 Publishing (ME)
4 1 13 Presentations
4 2 14 Presentations (2)
4 3 15 Research toolkit
4 4 16 Closing
import tabulate
import pandas as pd
times = pd.DataFrame(times, columns=["Slot", "Timings"])
timetable = pd.DataFrame(timetable, columns=["Day", "Slot", "Row", "Title"])
#timetable = timetable.assign(Title=lambda x: x.apply(fmt_i, axis=1))
timetable = timetable.drop(columns=['Row'])
timetable = timetable.join(times.set_index("Slot"), on="Slot")
timetable = timetable.pivot(index="Timings", columns="Day", values="Title")
timetable.columns = [f"Day {d}" for d in timetable.columns]
with open("timetable.org", "w") as f:
print("* Timetable", file=f)
print(tabulate.tabulate(
timetable,
tablefmt="orgtbl", showindex=True, headers="keys"), file=f)
# for i in range(1, 5):
# print(f"** Day {i}")
# print(tabulate.tabulate(
# timetable[[f'Day {i}']],
# tablefmt="orgtbl", showindex=True, headers="keys"))
# ensure you set pyvenv-workon to ical first
import pandas as pd
from icalendar import Calendar, Event
from datetime import datetime
import re
mre = re.compile(r"([0-9]*:[0-9]*)--([0-9]*:[0-9]*)")
timeformat = "%H:%M"
def convert_time_range(s):
m = mre.match(s)
assert m
return (datetime.strptime(m[1], timeformat).time(),
datetime.strptime(m[2], timeformat).time())
slots = (pd.DataFrame(timetable, columns=["day", "slot", "row", "title"])
.assign(day=lambda x: x.day.astype(int))
)
times = (pd.DataFrame(times, columns=["slot", "times"])
.assign(slot=lambda x: x.slot.astype(int))
.assign(time_range=lambda x: x.times.apply(convert_time_range))
.drop(['times'], axis=1)
.set_index("slot")
)
daydate = (pd.DataFrame(daydate, columns=["day", "date"])
.assign(day=lambda x: x.day.astype(int),
date=lambda x: x.date.apply(lambda y: datetime.strptime(y, "%d/%m/%Y")))
.set_index("day")
)
slots = (slots.join(times, on='slot')
.join(daydate, on="day")
)
cal = Calendar()
cal.add('prodid', '-//My calendar product//mxm.dk//')
cal.add('version', '2.0')
for ix, row in slots.iterrows():
dstart = datetime.combine(row.date, row.time_range[0])
dend = datetime.combine(row.date, row.time_range[1])
event = Event()
event.add('summary', row.title)
event.add('location', "")
event.add('dtstart', dstart)
event.add('dtend', dend)
event.add('dtstamp', datetime.now())
cal.add_component(event)
with open("pgrweek.ics", "wb") as f:
f.write(cal.to_ical())
from os import system
system("rsync pgrweek.ics cogentee:public_html/pgrweek.ics")
slots.to_csv("slots.csv")