[OGo-XML-RPC] Importing contacts from delimited files
Adam Tauno Williams
xmlrpc@opengroupware.org
Fri, 13 Apr 2007 13:30:25 -0400
--=-h1ZgKIjRL1VEIR4RnA74
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
> Adam from the users@ mailing list recommended I hop on over here for a fe=
w=20
> questions/help with XML-RPC scripts.
> I was told its possible and actually VERY easy to import a number of cont=
acts=20
> from a delimited file using Python/XML-RPC scripts. I was wondering if s=
omeone
> 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 =3D xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/RPC2')
reader =3D csv.reader(open("{FILENAME}", "rb"), delimiter=3D'|',
quoting=3Dcsv.QUOTE_NONE)
for row in reader:
person =3D {}
person['firstname'] =3D row[0]
person['name'] =3D row[1]
person['isPrivate'] =3D '1'
person['extendedKeys'] =3D ['email1', 'title', 'other_title1']
person['extendedAttrs'] =3D {}
person['extendedAttrs']['email1'] =3D row[5]
person['extendedAttrs']['job_title'] =3D row[3]
person['extendedAttrs']['other_title1'] =3D row[2]
person['phones'] =3D {}
person['phones']['01_tel'] =3D {}
person['phones']['01_tel']['number'] =3D row[4]
person =3D server.person.insert(person)
person =3D server.person.getById(person)
print person
> Also, can someone recommend some information on 'PUT'ing contacts via Zid=
estore 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.
=46rom WMOGAG:
The command =E2=80=9Cwdfs %LOCALFOLDER% -a http://%HOSTNAME%/zidestore/so/%
USERNAME%/ -u %USERNAME% -p %PASSWORD%=E2=80=9D will mount the ZideStore fo=
lder
tree to the specified local folder. In order for normal users to mount
folders the =E2=80=9Cwdfs=E2=80=9D binary must be set-uid.
--=-h1ZgKIjRL1VEIR4RnA74
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQBGH74xLRePpNle04MRArX8AJ9ruzLjkjN5P4ijzaM9lslNFVIDZQCfbrlm
VCri85rqBAPzMCVe5UoM4gQ=
=AdYH
-----END PGP SIGNATURE-----
--=-h1ZgKIjRL1VEIR4RnA74--