, 3 min read
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:
- Force-stop calendar app in your Android phone
- Clear all calendar data in your Android phone
- Shut down your Android phone
- Log-off from all other Google accounts
- Shut down your browser (I am not sure whether this step is really necessary, but better safe)
- Fire up your browser once again and log-in to Google
- Import your data, see screenshot below (I use the iCalendar format)
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".