Thanks, Des!
This looks like just what I wanted.
Cheers, -Brian
Thus spake Des Dougan ([EMAIL PROTECTED]):
On Tue, 2004-07-27 at 09:23, Brian Elliott Finley wrote:This kinda works.
My problem is that I'm not exporting them from Evolution, to then import them into another instance of Evolution. Instead, I've got the data in a raw format, and I'm trying to use my perl-foo to put the data into a "mass export style" .vcf card.
I've got the data so that it looks right to the naked eye, but I know I must be missing some kind of delimeter, as evolution only takes in the first couple of records (successfully), then silently declines the rest of the data.
If I remove those first couple of records from the file, then it doesn't accept any more.
I believe what I need at this point is a nice tidy detailed description of what Evolution is expecting (format and delimiter wise) from a .vcf file. I'm going through the vcard-21 spec, but I'm not convinced that evolution's expectations are the same as the vcard-21 spec.
Can anyone point me at an evolution .vcf card import spec document?
Brian,
I imported stuff from my Mozilla address books a little while ago. When searching, I found a PERL script called mozldif2vcf that did a fairly good job. I can't recall the site I found it on, but I've pasted the content below. Hope it provides some help.
Des
------
#!/usr/bin/perl
%R = {};
while ($line = <>) {
if ($line =~ /^dn:/) { dumpvcf(\%R) if %R; %R = {}; } else { map { if ($line =~ /^$_:\s*(.+)$/) {$R{$_} = $1} } qw(c cn custom1 facsimileTelephoneNumber givenName homePhone homePostalAddress homeurl l mail mobile mozillaHomeCountryName mozillaHomeLocalityName mozillaHomePostalAddress2 mozillaHomePostalCode mozillaHomeState mozillaPostalAddress2 mozillaSecondEmail o postalAddress postalCode sn st telephoneNumber title); }
}
sub dumpvcf {
my $r = shift or die "Need a hash of the record!"; my %R = %{$r};
print qq^BEGIN:VCARD VERSION:2.1 ^;
if ($R{'givenName'} ne '' && $R{'sn'} ne '') { print "X-EVOLUTION-FILE-AS:$R{'sn'}, $R{'givenName'}\n"; } else { print "X-EVOLUTION-FILE-AS:$R{'sn'}$R{'givenName'}\n"; }
$prefix = $R{'cn'}; $prefix =~ s/$R{'givenName'}//; $prefix =~ s/$R{'sn'}//; $prefix =~ s/^\s+//; $prefix =~ s/\s+$//; $R{'prefix'} = $prefix;
print "FN:$R{'cn'} N:$R{'sn'};$R{'givenName'};$R{'prefix'} ";
if ($R{'homePostalAddress'} ne '') { print "ADR;HOME:;$R{'mozillaHomePostalAddress2'};$R{'homePostalAddress'};$R{'mozillaHomeLocalityName'};$R{'mozillaHomeState'};$R{'mozillaHomePostalCode'};$R{'mozillaHomeCountryName'} LABEL;QUOTED-PRINTABLE;HOME:" . quotedprintable("$R{'homePostalAddress'}\n$R{'mozillaHomePostalAddress2'}\n$R{'mozillaHomeLocalityName'}, $R{'mozillaHomeState'} $R{'mozillaHomePostalCode'}\n$R{'mozillaHomeCountryName'}") . "\n";
}
if ($R{'postalAddress'} ne '' && $R{'postalAddress'} ne $R{'homePostalAddress'}) { print "ADR;WORK:;$R{'mozillaPostalAddress2'};$R{'postalAddress'};$R{'l'};$R{'st'};$R{'postalCode'};$R{'c'} LABEL;QUOTED-PRINTABLE;WORK:" . quotedprintable("$R{'postalAddress'}\n$R{'mozillaPostalAddress2'}\n$R{'l'}, $R{'st'} $R{'postalCode'}\n$R{'c'}") . "\n"; }
if ($R{'homePhone'} ne '') { print "TEL;HOME;VOICE:$R{'homePhone'} "; }
if ($R{'telephoneNumber'} ne '') { print "TEL;WORK;VOICE:$R{'telephoneNumber'} "; }
if ($R{'facsimileTelephoneNumber'} ne '') { print "TEL;WORK;FAX:$R{'facsimileTelephoneNumber'} "; }
if ($R{'mobile'} ne '') { print "TEL;CELL:$R{'mobile'} "; }
for my $e ('mail', 'mozillaSecondEmail') { print "EMAIL;INTERNET:$R{$e} " if $R{$e} ne ''; }
print "URL:$R{'homeurl'} ORG:$R{'o'} TITLE:$R{'title'} NOTE:$R{'custom1'}$R{'custom2'}$R{'custom3'} END:VCARD
";
}
sub quotedprintable { my $toencode = shift; $toencode =~ s/\n+/\n/; $toencode =~ s/([^a-zA-Z0-9_.-])/uc sprintf("=%02x",ord($1))/eg; return $toencode; }
--
Des Dougan, Principal Dougan Consulting Group
Ph: 604-980-2848 Email: des at DouganConsulting dot com
www.DouganConsulting.com
Design - Implementation - Support
_______________________________________________ evolution maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/evolution
--
------------------------------------------------------
Brian Elliott Finley Argonne, MCS Division Mobile: 630.631.6621 Office: 630.252.4742
gpg --keyserver wwwkeys.pgp.net --recv-keys 10F8EE52
------------------------------------------------------
_______________________________________________
evolution maillist - [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/evolution
