SYNOPSIS

paddpdb2bib [--encfrom=...] [--encto=...] [--first-last] [ <custom field mappings> ] AddressDB.pdb


DESCRIPTION

Given a PDB file from one's Address Book on a pilot device (one that is parseable by Palm::Address), output a database in bibtex format that is suitable for processing via the directory LaTeX macro package.


OPTIONS

h
help
?

Print usage instructions to STDERR.

man

Print the manual page to STDOUT.

v
V
version

Print the version information to STDOUT.

encfrom

Name of the encoding from which to transcode the text fields in the PDB.

encto

Name of the encoding to which to transcode the output bibtex fields text. Defaults to the same encoding as given by the encfrom option.

url
birthday
father or middle
spouse

These 4 options provide a way to map the custom fields to URL, birthday, patronymic, and spouse name, respectively. An unmapped custom fields will be added to the note field, labeled the same way as they are custom named in the PDB.

first-last

Boolean option, if set, the names will be output in the First Last format. Otherwise (the default), they are output as Last, First. The option is there since some documents consider this the ``preferred named format''.

If the middle name field mapping is specified, the output becomes First Middle Last, and Last, First Middle respectively. Note that in pathological cases (e.g., if somebody has a first name and a patronymic, but not a last name in your database) this may affect the sorting order in a wrong way, because bibtex has no way to distinguish a bare First Middle from a legal First Last.

Finally, in the First ... Last format sometimes the first and last names are arbitrarily guessed by the bibtex the wrong way around, and thus the corresponding contact is sorted wrongly as well. Using the default Last, First ... format usually helps in such cases.


BIBTEX FIELDS

Follows a snapshot from the documentation of the directory LaTeX package, on which the fields emitted by this script are marked with a corresponding comment in the end, detailing from which Palm::Address fields they are extracted.

The decision whether to emit @person or @company is based on whether the ``name'' fields of the person is defined.

        @person{key, % of the form contact:<palm record id>
          name = "Full name(s), in standard BibTeX format", % name, firstName father
          nickname = "Nickname(s)",
          birthday = "Birthday date(s), in numeric 'day month' format", % from birthday
          birthyear = "Birth year(s)", % from birthday
          p.street = "Street of private residence", % address
          p.city = "City of private residence", % city
          p.zip = "ZIP code of private residence", % zipCode
          p.state = "State of private residence", % state
          p.country = "Country of private residence", % country
          p.phone = "Private phone number", % "Home" phone[1-5] fields
          p.cellular = "Private mobile phone number", % "Mobile" and "Pager" phone[1-5] fields
          p.fax = "Private fax number", % "Fax" phone[1-5] fields
          p.email = "Private e-mail address", % "E-mail" phone[1-5] fields
          p.url = "Private home page", % url
          p.account = "Private bank account",
          r.street = "Street of alternative residence",
          r.city = "City of alternative residence",
          r.zip = "ZIP code of alternative residence",
          r.state = "State of alternative residence",
          r.country = "Country of alternative residence",
          r.phone = "Alternative phone number", % "Other" phone[1-5] fields
          r.cellular = "Alternative mobile phone number",
          r.fax = "Alternative fax number",
          r.email = "Alternative e-mail address",
          r.url = "Alternative home page",
          r.account = "Alternative bank account",
          w.name = "Work organization name", % company
          w.title = "Job title", % title
          w.street = "Street of work organization",
          w.city = "City of work organization",
          w.zip = "ZIP code of work organization",
          w.state = "State of work organization",
          w.country = "Country of work organization",
          w.phone = "Work phone number",  % "Work" and "Main" phone[1-5] fields
          w.cellular = "Work mobile phone number",
          w.fax = "Work fax number",
          w.email = "Work e-mail address",
          w.url = "Work home page",
          w.account = "Work bank account",
          note = "Additional notes about the person", % unmapped+note
        }

For a @company entry the phone fields are concatenated together from the given [rpw].... alternatives.

        @company{key, % of the form contact:<palm record id>
          name = "Company name", % company
          street = "Company street", % address
          city = "Company city", % city
          zip = "Company ZIP code", % zipCode
          state = "Company state", % state
          country = "Company country", % country
          phone = "Company phone number",
          cellular = "Company mobile phone number",
          fax = "Company fax number",
          email = "Company e-mail address",
          url = "Company home page",
          account = "Company bank account",
          note = "Additional notes about the company", % unmapped+note
        }


INSTALLATION

Download the prerequisite Perl modules for this script from CPAN, and then you'll be able to run the present script as well.

Install directory from CTAN, unless you already have it installed as a part of your TeX distribution.


EXAMPLE

Fetch the AddressDB.pdb from your pilot, for example, by using pilot-xfer(1). Create a file all.tex as the master document to format your address book, e.g.:

        \documentclass[a4paper,twocolumn]{article} % vim:fileencoding=cp1251
        \usepackage[T2A]{fontenc}
        \usepackage[cp1251]{inputenc}
        \usepackage[obeyspaces]{url} % so "Foo Bar <foo@bar.org>" appears with the spacing inside!
        \usepackage{fullpage}
        \usepackage[longdates]{directory}
        \raggedbottom\raggedright
        \renewcommand{\dirand}{$\heartsuit$}
        \pagestyle{empty}
        \directorystyle{address}
        \begin{document}
        \nodir{*}
        \directory{all}
        \today
        \end{document}

Then convert the PDB to the bibtex database, and format the document:

        $ paddpdb2bib --encfrom=cp1251 \
                --url=custom1 --birthday=custom2 --father=custom3 --spouse=custom4 \
                AddressDB.pdb > all.bib
        $ texi2dvi all.tex
        $ bibtex all.aux
        $ texi2dvi all.tex


HISTORY

        $Log: paddpdb2bib,v $
        Revision 1.7  2007/02/05 17:20:31  vassilii
        pod docs only:
        1) eliminate from BUGS the one about email typesetting,
        and add to the EXAMPLE a corresponding incantation for package {url}
        2) SEE ALSO - hyperlinking
        Revision 1.6  2007/01/15 16:52:26  vassilii
        In the Last, First format don't start with the comma
        if there is no Last name. The new scheme is the best default
        w.r.t. the sorting of non-latin contacts. Switched the default,
        the cmdline, and the pod docs accordingly. Finally, no sorting
        glitches in my versatile phonebook!
        Revision 1.5  2007/01/12 18:35:48  vassilii
        BUG fixed in the birthday sorting order - now 0-padding the numbers to 2 digits
        the output now includes a descriptive header in a comment format
        documented --version option
        Revision 1.4  2007/01/12 13:10:28  vassilii
        added --version cmdline option
        restored the spouse to work in the First Last ordering as well
        Revision 1.3  2007/01/12 03:33:29  vassilii
        RCS kwds in the pod
        only the "guest" ambiguous phones are now labeled 
                (like (Pager) in the mobile fields)
        workaround posted for the directory \dircheck bug
        pod updates


BUGS

With non-Latin encodings, bibtex(1) is pretty freaky. You might need to procure a custom patched bibtex version that works with your national encoding.

For some reason, the directory package, coupled with LaTeX and Bibtex on my system fails to properly sort the produced entries when I use the koi8-r encoding (sorting them in the YU A B C D order, i.e., according to the Latin alphabet), so for a decent sorting of Russian one has to use the cp1251 code page.

The \dircheck macro only calls \Dirheader for the first Russian letter present in the sorted output, and never works for the subsequent ones. This is a bug in the directory package, and a patch against its version 1.20 has been submitted upstream. You can download the same patch separately from http://www.tarunz.org/~vassilii/pub/dircheck.diff.

Some escaping debugging might be in order, as well as general code beautification.

More intelligent guessing of ambiguous mapping between the PDB and bibtex fields might be in order, maybe based on category and which fields are present.

Adding to the note field could also be made configurable on a per-field basis, as well as overflowing extra phones of the same type to the note.

The birthday dates are passed using HTTP::Date internal heuristics. Some more generic ways could be used, such as using the on-palm format for dates, or unleashing various DateTime::Format beasts. (bork! bork!)

Maybe per-category export?


SEE ALSO

CTAN entry for the directory package, Palm::Address(3), bibtex(1), texi2dvi(1), HTTP::Date(3)


AUTHOR

Vassilii Khachaturov <vassilii@tarunz.org>


LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html