Importing Calendar Data to Google-Calendar

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

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.

use strict;
use Getopt::Std;

my %opts;
getopts('s:e:',\%opts);
my ($dtstart,$dtend) = ("00000000","99999999");
$dtstart = $opts{'s'} if (defined($opts{'s'}));
$dtend = $opts{'e'} if (defined($opts{'e'}));

my @stack = ();
my ($beginv, $i, $flag) = (0,0,0);
$dtstart = (length($dtstart) < 8) ?
        $dtstart . substr("00000000",0,8 - length($dtstart)) : substr($dtstart,0,8);
$dtstart = "DTSTART:${dtstart}T000000";
$dtend = (length($dtend) < 8) ?
        $dtend . substr("00000000",0,8 - length($dtend)) : substr($dtend,0,8);
$dtend = "DTSTART:${dtend}T000000";

print "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Judd Montgomery//NONSGML J-Pilot 1.8.1.2//EN\n";

while (<>) {
        next if (/^UID:/);      # Google does not need the UID, so drop it
        $beginv = 1 if (/^BEGIN:VEVENT/);
        $beginv = 0 if (/^END:VEVENT/);

        if ($beginv == 1) {
                $stack[++$#stack] = $_;
                $flag = 1 if (/^DTSTART:/  &&  $_ ge $dtstart  &&  $_ le $dtend);
        } elsif ($beginv == 0) {
                if ($flag == 1) {
                        for ($i=0; $i<=$#stack; ++$i) {
                                print $stack[$i];
                        }
                        print;
                }
                $flag = 0;
                @stack = ();
        }
}

print "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:

palmcalfrom -s1900 -e19990000 jcal150318 > f1.ical
palmcalfrom -s19990000 -e20010000 jcal150318 > f2.ical
palmcalfrom -s20010000 -e20030000 jcal150318 > f3.ical
palmcalfrom -s20030000 -e20050000 jcal150318 > f4.ical
palmcalfrom -s20050000 -e20080000 jcal150318 > f5.ical
palmcalfrom -s20080000 -e20110000 jcal150318 > f6.ical
palmcalfrom -s20110000 -e20140000 jcal150318 > f7.ical
palmcalfrom -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

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s