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!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Jon Udell

InfoWorld
Show Comments

Cool Tech

SanDisk MicroSDXC™ for Nintendo® Switch™

Learn more >

Breitling Superocean Heritage Chronographe 44

Learn more >

Toys for Boys

Family Friendly

Panasonic 4K UHD Blu-Ray Player and Full HD Recorder with Netflix - UBT1GL-K

Learn more >

Stocking Stuffer

Razer DeathAdder Expert Ergonomic Gaming Mouse

Learn more >

Christmas Gift Guide

Click for more ›

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

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.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?