Importing Calendar Data to Google-Calendar

· klm's blog


Original post is here: eklausmeier.goip.de

Importing calendar data to Google is still troublesome for a number of reasons. What seems to work goes like this:

  1. Force-stop calendar app in your Android phone
  2. Clear all calendar data in your Android phone
  3. Shut down your Android phone
  4. Log-off from all other Google accounts
  5. Shut down your browser (I am not sure whether this step is really necessary, but better safe)
  6. Fire up your browser once again and log-in to Google
  7. Import your data, see screenshot below (I use the iCalendar format)

importCal1

[more_WP_Tag]

importCal2

Deleting all my calendar data in Google did not work when I did not log-off from Google and my Android phone was still switched on. In that case Google told me it was unable to delete all my data.

Importing calendar data is still a quagmire, as Google does not allow files larger than 1 MB, see Trouble importing iCalendar files. So you have to split your files. For splitting my calendar data, which I exported from J-Pilot, I use the following Perl script to split the data.

 1use strict;
 2use Getopt::Std;
 3
 4my %opts;
 5getopts('s:e:',\%opts);
 6my ($dtstart,$dtend) = ("00000000","99999999");
 7$dtstart = $opts{'s'} if (defined($opts{'s'}));
 8$dtend = $opts{'e'} if (defined($opts{'e'}));
 9
10my @stack = ();
11my ($beginv, $i, $flag) = (0,0,0);
12$dtstart = (length($dtstart) < 8) ?
13        $dtstart . substr("00000000",0,8 - length($dtstart)) : substr($dtstart,0,8);
14$dtstart = "DTSTART:${dtstart}T000000";
15$dtend = (length($dtend) < 8) ?
16        $dtend . substr("00000000",0,8 - length($dtend)) : substr($dtend,0,8);
17$dtend = "DTSTART:${dtend}T000000";
18
19print "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Judd Montgomery//NONSGML J-Pilot 1.8.1.2//EN\n";
20
21while (<>) {
22        next if (/^UID:/);      # Google does not need the UID, so drop it
23        $beginv = 1 if (/^BEGIN:VEVENT/);
24        $beginv = 0 if (/^END:VEVENT/);
25
26        if ($beginv == 1) {
27                $stack[++$#stack] = $_;
28                $flag = 1 if (/^DTSTART:/  &&  $_ ge $dtstart  &&  $_ le $dtend);
29        } elsif ($beginv == 0) {
30                if ($flag == 1) {
31                        for ($i=0; $i<=$#stack; ++$i) {
32                                print $stack[$i];
33                        }
34                        print;
35                }
36                $flag = 0;
37                @stack = ();
38        }
39}
40
41print "END:VCALENDAR\n";

The code is also in GitHub.

Importing a 1 MB file takes around 120-180 seconds for Google to import, so each import is quite slow and the whole procedure feels bulky. The process is therefore:

1palmcalfrom -s1900 -e19990000 jcal150318 > f1.ical
2palmcalfrom -s19990000 -e20010000 jcal150318 > f2.ical
3palmcalfrom -s20010000 -e20030000 jcal150318 > f3.ical
4palmcalfrom -s20030000 -e20050000 jcal150318 > f4.ical
5palmcalfrom -s20050000 -e20080000 jcal150318 > f5.ical
6palmcalfrom -s20080000 -e20110000 jcal150318 > f6.ical
7palmcalfrom -s20110000 -e20140000 jcal150318 > f7.ical
8palmcalfrom -s20140000 jcal150318 > f8.ical

One might ask why split the source calendar data according dates, as done above in palmcalfrom? It would be much easier to just count the BEGIN:VEVENT and after a fixed number of them flush a new file. The reason is that, as the import is so slow, it is easier to add calendar data for the rest of the year with palmcalfrom -s icalFile

Some years ago importing data into Google Contacts was also very slow and messy. Luckily Google put some effort into this, so you can now delete all your contacts and re-import your whole stuff. Unfortunately, deleting all contacts is still very cumbersome, as you can only delete 500 records one at a time.

It is not only deleting and importing data into Google Calendar that is quite difficult, but also moving to widely different dates, Google has problems, see message below which always occurs when you move to different dates "fast".

GoogleCalProb1