[jp] Possible to jpilot-dump a ContactsDB?

Nicholas Piper nick-moongroup at nickpiper.co.uk
Tue Sep 15 05:23:35 EDT 2009


Ng,

On Mon, 14 Sep 2009, Ng Oon-Ee wrote:

> Is it possible to use jpilot-dump on a ContactsDB database? Wish to
> script a regular export of my jpilot contact list (which is in a
> ContactsDB, from my Centro) to evolution, the rest of the scripting is
> easy (basically string adjustment using sed), but I still have to
> manually export a csv from jpilot instead of being able to just use
> jpilot-dump as I can for memos and calendars.

You can do this from Python, if you got jppy working. (I'm the author
of jppy, and it's been a little broken recently.)

Here's an example, using the current Jppy API. Older versions are a
tiny bit different as they don't have an 'environment' object.

#!/usr/bin/jppy

import jppy
import csv
import sys

env = jppy.environment.Environment()

csvWriter = csv.writer(open('/tmp/addresses.csv', 'w'), delimiter=',',
                       quotechar='"', quoting=csv.QUOTE_MINIMAL)

# this uses ContactsDB, depending on your ~/.jppyrc:
# [jppy]
# addressbook = jppy.jpilot.modern.addressBook
# #addressbook = jppy.jpilot.legacy.addressBook


for record in env.addressBook.records():
    details = []
    # python csv module doesn't support unicode :-(
    details.append(record["firstname"].encode('utf8'))
    details.append(record["lastname"].encode('utf8'))
    details.append(record["email"])

    csvWriter.writerow(details)
        

As you have full Python available, you might decide not to use a
temporary CSV file and instead go straight to evolution with some
Python bindings.

(Hmm, maybe I should have written a Conduit plugin for jpilot by now?)

 Nick



More information about the Jpilot mailing list