2 Feb 2011 connolly   » (Master)

Cleaning up my contacts with batch edits in the Google Contacts Data API

The Blizzard of Oz snow day gave me a chance to get my taxes done yesterday, and today I used the time to scratch a long-standing itch to clean up my contacts, which have been a bit of a mess since I merged two sources into one.



When I got my first android phone, a G1, I used the
Google Contacts Data API to write hipg.py for migrating my sidekick/hiptop contacts to gmail contacts. Then I grew disappointed with the G1 and went back to the sidekick. And then Microsoft bought Danger and lost everybody's sidekick contacts for a week or so. They restored some of the data, but all my street addresses were gone. I had back-ups, of course; I know better than to completely trust any cloud provider. But I hadn't written code to restore from my back-ups. So I lived without street addresses in my phone for a while.

Then I got another android phone, a Samsung Galaxy S Vibrant. I migrated the sidekick contacts again, and then, to get the street addresses, I imported the contacts from the G1 days. Google's merge tools cleaned things up to a tolerable level, but they left 2 issues:

  1. Duplicate phone numbers like:
  • +1-212-555-1212
  • 212-555-1212
  • Duplicated notes like:
    alllinestogether

    all
    lines
    like they should be

  • I fixed a few of these by hand, but knowing that I could get the computer to do them all in batch has been itching at me for a while.

    It took just a few hours and a couple hundred lines of python to scratch that itch today with contact_fix.py.


    475:c87196981537 2011-02-02 fix all_contacts (self.)
    474:80739018dbfa 2011-02-02 - make group optional; default to all
    473:61412465cfed 2011-02-02 - fix duplicate phone numbers as well as doubled notes
    472:01c2becd5cfb 2011-02-02 batch edit works/tested in one case
    471:e7840a73836d 2011-02-02 batch edit operation (tested non-destructively)
    470:e4e531aae635 2011-02-02 run fix_note() on data from the server
    469:2ec84b8d0363 2011-02-02 - print names of contacts in a group
    468:b919239097e7 2011-02-02 contact_fix.py can login and get contact data

    I'm also working on archiving my contacts using hCard. More on that soon, I hope.

    Syndicated 2011-02-02 22:19:00 (Updated 2011-09-23 08:27:00) from Dan Connolly

    Latest blog entries     Older blog entries

    New Advogato Features

    New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

    Keep up with the latest Advogato features by reading the Advogato status blog.

    If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!