]> pere.pagekite.me Git - homepage.git/blob - blog/data/2017-01-04-icalendar-archiver.txt
Generated.
[homepage.git] / blog / data / 2017-01-04-icalendar-archiver.txt
1 Title: Introducing ical-archiver to split out old iCalendar entries
2 Tags: english, standard
3 Date: 2017-01-04 12:20
4
5 <p>Do you have a large <a href="https://icalendar.org/">iCalendar</a>
6 file with lots of old entries, and would like to archive them to save
7 space and resources? At least those of us using KOrganizer know that
8 turning on and off an event set become slower and slower the more
9 entries are in the set. While working on migrating our calendars to a
10 <a href="http://radicale.org/">Radicale CalDAV server</a> on our
11 <a href="https://freedomboxfoundation.org/">Freedombox server</a/>, my
12 loved one wondered if I could find a way to split up the calendar file
13 she had in KOrganizer, and I set out to write a tool. I spent a few
14 days writing and polishing the system, and it is now ready for general
15 consumption. The
16 <a href="https://github.com/petterreinholdtsen/ical-archiver">code for
17 ical-archiver</a> is publicly available from a git repository on
18 github. The system is written in Python and depend on
19 <a href="http://eventable.github.io/vobject/">the vobject Python
20 module</a>.</p>
21
22 <p>To use it, locate the iCalendar file you want to operate on and
23 give it as an argument to the ical-archiver script. This will
24 generate a set of new files, one file per component type per year for
25 all components expiring more than two years in the past. The vevent,
26 vtodo and vjournal entries are handled by the script. The remaining
27 entries are stored in a 'remaining' file.</p>
28
29 <p>This is what a test run can look like:
30
31 <p><pre>
32 % ical-archiver t/2004-2016.ics
33 Found 3612 vevents
34 Found 6 vtodos
35 Found 2 vjournals
36 Writing t/2004-2016.ics-subset-vevent-2004.ics
37 Writing t/2004-2016.ics-subset-vevent-2005.ics
38 Writing t/2004-2016.ics-subset-vevent-2006.ics
39 Writing t/2004-2016.ics-subset-vevent-2007.ics
40 Writing t/2004-2016.ics-subset-vevent-2008.ics
41 Writing t/2004-2016.ics-subset-vevent-2009.ics
42 Writing t/2004-2016.ics-subset-vevent-2010.ics
43 Writing t/2004-2016.ics-subset-vevent-2011.ics
44 Writing t/2004-2016.ics-subset-vevent-2012.ics
45 Writing t/2004-2016.ics-subset-vevent-2013.ics
46 Writing t/2004-2016.ics-subset-vevent-2014.ics
47 Writing t/2004-2016.ics-subset-vjournal-2007.ics
48 Writing t/2004-2016.ics-subset-vjournal-2011.ics
49 Writing t/2004-2016.ics-subset-vtodo-2012.ics
50 Writing t/2004-2016.ics-remaining.ics
51 %
52 </pre></p>
53
54 <p>As you can see, the original file is untouched and new files are
55 written with names derived from the original file. If you are happy
56 with their content, the *-remaining.ics file can replace the original
57 the the others can be archived or imported as historical calendar
58 collections.</p>
59
60 <p>The script should probably be improved a bit. The error handling
61 when discovering broken entries is not good, and I am not sure yet if
62 it make sense to split different entry types into separate files or
63 not. The program is thus likely to change. If you find it
64 interesting, please get in touch. :)</p>
65
66 <p>As usual, if you use Bitcoin and want to show your support of my
67 activities, please send Bitcoin donations to my address
68 <b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&label=PetterReinholdtsenBlog">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p>