Data export, delivered

From time to time I get recruited to help someone export mail and contacts from one e-mail program and import the data into another. The fact that a civilian must recruit a geek to accomplish this seemingly mundane task speaks volumes about our industry's sad history of data lock-in.

Even for a geek, the solution can easily become a slide down a slippery slope. There's no shortage of converters floating around on the Net, but it's surprisingly hard to find one that will reliably and completely transform, say, WAB (Windows Address Book) to LDIF (LDAP Data Interchange Format) or CSV (comma-separated values).

Back in 2002, I discovered that Mozilla's mail program, now known as Thunderbird, could import mail and contacts from an Outlook PST file and then export the data as Mbox for mail and LDIF or CSV for contacts. My referral log tells me that, to this day, people continue to seek out and use that technique.

It came in handy again this week when a friend wanted to switch from Outlook Express to Gmail. Exporting her contacts to a CSV file, and then importing them into Gmail, turned out to be a snap. But when I declared victory, she sent me scrambling down the slippery slope with this innocent-sounding question: "What about my distribution lists?"

Uh-oh. It turns out that she uses 15 lists, some with just a few individual addresses and some with more than 100. Those lists didn't appear in the CSV file, or in the output of any other WAB converter I could find. Even my trusty Thunderbird trick only partly worked. Although Thunderbird can export lists to LDIF, it does only one at a time, so I had to create a file for each separate list. Grumble.

With half the battle won, how to inject those LDIF files into Gmail? There's no official Google-supported API, but I've gotten lots of mileage out of an unofficial one called libgmail. Good news: libgmail has added support for Gmail contacts since I last used it. Bad news: It only supports individual contacts, not lists.

The solution I cobbled together speaks volumes about the fundamental openness of Web applications. To find out how Gmail creates a distribution list, I logged in, created a list interactively using Gmail's form, and captured the resulting HTTP transaction using one of the handiest tools in my Web developer's kit, Firefox's LiveHTTPHeaders extension.

The next step was to replay that transaction outside of the browser. I rearranged its elements -- a URL, a chunk of HTTP POST data, and a set of HTTP headers including a cookie packed with crucial name/value pairs -- as a command-line invocation of another of the handiest tools in my kit: curl.

As proof of concept, I used Gmail's interface to delete the list I'd just made, then invoked the curl command to recreate it. When that worked, I wrote a simple script to interpolate names and addresses from the exported LDIF files into a series of curl commands, and invoke them one at a time. And that was that.

It was only a partial solution, of course. A fully automated version would tie into libgmail's authentication scheme, obviating the need to capture and replay an HTTP header. But the fact that it's possible to discover and exploit implicit APIs in this way is a testament to the power and flexibility of the Web's architectural style.

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Jon Udell

InfoWorld
Show Comments

Father’s Day Gift Guide

Brand Post

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Luke Hill

MSI GT75 TITAN

I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Laura Johnston

MSI GS65 Stealth Thin

If you can afford the price tag, it is well worth the money. It out performs any other laptop I have tried for gaming, and the transportable design and incredible display also make it ideal for work.

Andrew Teoh

Brother MFC-L9570CDW Multifunction Printer

Touch screen visibility and operation was great and easy to navigate. Each menu and sub-menu was in an understandable order and category

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?