title: Sorting icalendar events chronologically
body: <p>I need to convert a large set of ics icalendar events into a LaTeX pgfgantt chart. For this I wrote a tiny script with the help of an answer found <a href="https://stackoverflow.com/questions/20937754/parsing-ical-feed-with-python-using-icalendar">here</a>.</p>
  <pre><code>from icalendar import Calendar, Event
  from datetime import datetime
  from pytz import UTC # timezone
  
  g = open('calendar.ics','rb')
  gcal = Calendar.from_ical(g.read())
  for component in gcal.walk():
      if component.name == &quot;VEVENT&quot;:
          start = component.get('dtstart')
          end = component.get('dtend')
          print(&quot;\ganttbar{&quot;+ str(component.get('summary')) + &quot;}{&quot; + str(start.dt) + &quot;}{&quot; + str(end.dt) + &quot;}\\\\&quot;)
  g.close()
  </code></pre>
  <p>The path has to be absolute for some reason.</p>