Home | My Writings |
If you are using Evolution, and you want to migrate to something better (like Mozilla Thunderbird), this may be helpful to you. Evolution can export its addressbook to a vcard format, but Mozilla Thunderbird cannot import vcard addressbook. The script will export your evolution addressbook to a tab seperated file which you can then import into Thunderbird. And hopefully live happily after.
You need the following two scripts -
Copy these two scripts, do a chmod a+x exportevolution.py
and chmod a+x vcard2csv.pl
. Next use the following command ./exportevolution.py|./vcard2csv.pl >addressbook.csv
. You will have your arressbook in addressbook.csv . If you have found an easier way to do it, please let me know.
===start file exportevolution.py=== #!/usr/bin/python2 import bsddb, os, re home = os.getenv('HOME') # This is the only variable you should change. If you do not know the # location of your evloution address book, use `locate addressbook.db` # to find it dbname = '%s/evolution/local/Contacts/addressbook.db' % home db = bsddb.hashopen(dbname, 'r') for k in db.keys(): for line in db[k].split('\n'): print line db.close() ===end file exportevolution.py=== ===start file vcard2tab.pl=== #!/usr/bin/perl use strict; my $line; my $name; my $tel_work_voice; my $tel_work_fax; my $tel_home; my $tel_pager; my $tel_cell; my $tel_voice; my $email; while ( $line = < STDIN > ) { chomp ($line); chop ($line) ; # trailing ^M #BEGIN:VCARD if ( $line eq "BEGIN:VCARD" ) { $name = ""; $tel_work_voice = ""; $tel_work_fax = ""; $tel_home = ""; $tel_pager = ""; $tel_cell = ""; $tel_voice = ""; $email = ""; } #X-EVOLUTION-FILE-AS: if ( $line =~ /^X-EVOLUTION-FILE-AS\:.*/ ) { $line =~ s/^X-EVOLUTION-FILE-AS://g; $name = $line; print $name." "; print "\t"; } #TEL;WORK;VOICE; if ( $line =~ /^TEL;WORK;VOICE:.*/ ) { $line =~ s/^TEL;WORK;VOICE://g; $tel_work_voice = $line; } #TEL;WORK;FAX; if ( $line =~ /^TEL;WORK;FAX:.*/ ) { $line =~ s/^TEL;WORK;FAX://g; $tel_work_fax = $line; } #TEL;HOME; if ( $line =~ /^TEL;HOME:.*/ ) { $line =~ s/^TEL;HOME://g; $tel_home = $line; } #TEL;PAGER; if ( $line =~ /^TEL;PAGER:.*/ ) { $line =~ s/^TEL;PAGER://g; $tel_pager = $line; } #TEL;CELL; if ( $line =~ /^TEL;CELL:.*/ ) { $line =~ s/^TEL;CELL://g; $tel_cell = $line; } #TEL;VOICE; if ( $line =~ /^TEL;VOICE:.*/ ) { $line =~ s/^TEL;VOICE://g; $tel_voice = $line; } #EMAIL;INTERNET; if ( $line =~ /^EMAIL;INTERNET:.*/ ) { $line =~ s/^EMAIL;INTERNET://g; $email = $email.$line; } #EMAIL;QUOTED-PRINTABLE;INTERNET; if ( $line =~ /^EMAIL;QUOTED-PRINTABLE;INTERNET:.*/ ) { $line =~ s/^EMAIL;QUOTED-PRINTABLE;INTERNET://g; $line =~ s/=0A/ /g; #=0A make it a space $email = $email.$line; } #END:VCARD if ( $line eq "END:VCARD" ) { if ( $tel_work_voice eq "" ) { print ",";} else { print "wk=".$tel_work_voice.","; } if ( $tel_work_fax eq "" ) { print ","; } else {print "fx=".$tel_work_fax.","; } if ( $tel_home eq "" ) { print ","; } else { print "hm=".$tel_home.","; } if ( $tel_pager eq "" ) { print ","; } else { print "pg=".$tel_pager.","; } if ( $tel_cell eq "" ) { print ","; } else { print "cel=".$tel_cell.","; } if ( $tel_voice eq "" ) { print ","; } else { print "alt=".$tel_voice.","; } if ( $email eq "" ) {print ",";} else { print $email; } print "\n"; } } ===end file vcard2tab.pl===
Home | My Writings |
Send me your comments . Befoer mailing convert "at" in email addresses to "@" and remove any spaces in the email address. This is to prevent spamming.