Created
September 21, 2024 14:01
-
-
Save Wemmy0/660111abb0b82e8fd359ef9641d60466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Take an ICS file and split events into lectures and practicals based on their name | |
# Made for Newcastle University timetables downloaded from https://timetables.ncl.ac.uk/ | |
from ics import Calendar | |
with open('timetable.ics', 'r') as file: | |
ics_content = file.read() | |
events = list(Calendar(ics_content).events) | |
lecture = Calendar() | |
practical = Calendar() | |
for event in events: | |
if 'P' in event.name: | |
practical.events.add(event) | |
else: | |
lecture.events.add(event) | |
with open('lecture.ics', 'w') as file: | |
file.writelines(lecture.serialize_iter()) | |
with open('practical.ics', 'w') as file: | |
file.writelines(practical.serialize_iter()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment