[jp] Possible to jpilot-dump a ContactsDB?

Ng Oon-Ee ngoonee at gmail.com
Tue Sep 15 06:09:43 EDT 2009


On Tue, 2009-09-15 at 10:23 +0100, Nicholas Piper wrote:
> 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

Ah, first I've heard of jppy. I'll try it out when I get a block of time
to. Unfortunately no binaries of it here in Arch, so first thing I have
to do is get it installed =).

Thanks. Is jppy still being worked on?




More information about the Jpilot mailing list