Re: Importing contacts from delimited files

Adam Tauno Williams <[email protected]> Fri, 13 Apr 2007 13:30:25 -0400
Newsgroups gmane.comp.cms.opengroupware.xmlrpc.devel
Message-ID <[email protected]>
> Adam from the users@ mailing list recommended I hop on over here for a few 
> questions/help with XML-RPC scripts.
> I was told its possible and actually VERY easy to import a number of contacts 
> from a delimited file using Python/XML-RPC scripts.  I was wondering if someone
> could provide some help as to how this is actually done.

Here is one simple example -

#!/usr/bin/env python

import sys, csv, xmlrpclib, pprint
server = xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/RPC2')
reader = csv.reader(open("{FILENAME}", "rb"), delimiter='|',
quoting=csv.QUOTE_NONE)
for row in reader:
  person = {}
  person['firstname'] = row[0]
  person['name'] = row[1]
  person['isPrivate'] = '1'
  person['extendedKeys'] = ['email1', 'title', 'other_title1']
  person['extendedAttrs'] = {}
  person['extendedAttrs']['email1'] = row[5]
  person['extendedAttrs']['job_title'] = row[3]
  person['extendedAttrs']['other_title1'] = row[2]
  person['phones'] = {}
  person['phones']['01_tel'] = {}
  person['phones']['01_tel']['number'] =  row[4]
  person = server.person.insert(person)
  person = server.person.getById(person)
  print person

> Also, can someone recommend some information on 'PUT'ing contacts via Zidestore using vCard files?

You should be able to use any WebDAV client to PUT a vCard file to
ZideStore;  a URL like http://{HOST}/zidestore/dav/{USERNAME}/Contacts

I mount ZideStore to the filesytsem with FUSE from my openSUSE
workstation and one can navigate the tree with cd, ls, and friends.  On
Windows you should be able to do the same thing with WebDrive but I have
never tried it.

From WMOGAG:
The command “wdfs %LOCALFOLDER% -a http://%HOSTNAME%/zidestore/so/%
USERNAME%/ -u %USERNAME% -p %PASSWORD%” will mount the ZideStore folder
tree to the specified local folder. In order for normal users to mount
folders the “wdfs” binary must be set-uid.
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBGH74xLRePpNle04MRArX8AJ9ruzLjkjN5P4ijzaM9lslNFVIDZQCfbrlm
VCri85rqBAPzMCVe5UoM4gQ=
=AdYH
-----END PGP SIGNATURE-----