Thursday, January 27, 2011

Google Talk Chat History Export

I had been looking for a way to export my chat history from one Google account to another for a while.  It was driving me crazy.  Not having some way to preserve my chat history was the last thing that was keeping me from closing out my old Google account.

So then I stumbled upon this post by CandorZ.  He was more interested in archiving the chats, but he hinted me on to a strategy that I hadn't thought of before.  Basically, he proposes that you 1) assign a new label to all of your chats; 2) use offline sync to download all messages from the new label--offline sync will basically create an SQLite database of the chats on your computer; 3) extract the chats from the database.

CandorZ made available a script/executable that extracts each message from the database and saves its text as an HTML file.  I modified/enhanced his script to extract all fields necessary to construct a .eml file for each message.  The .eml files may be dragged and dropped into Windows Live Mail (and, I'm assuming, a number of other mail clients).  From there, you have a lot of options.  For instance, I dragged them over to the IMAP account for my new Gmail account.

Here is my modified script and the extraction utility.  Just follow CandorZ's instructions to use them.

8 comments:

  1. Wow man.. you have gone one step even further than CandorZ. You rock. even i felt that the dates are important as without them, the data can never be organised. you have won over that hurdle so easily.

    now a suggestion. when we r seeing a chat on gmail (online), there is an option to print it. when i click it, a new window pops open and display the chat in a very beautiful format alongwith neatly placed headings and subjects. can there be a script to downlaod those versions (displays) of the chat. or to display the downlaoded chat in that format. just try.. :) thanks.

    ReplyDelete
  2. It should be possible to do something like that. Someone with a little VB and SQL experience could probably modify the script to do it within less than an hour. I'm afraid I'm much to busy though to spend any more time on this myself, though.

    ReplyDelete
  3. You may want to double check your results. Looking at the output EMLs right now, I see several chats that are truncated with the "[Message clipped] View entire message" footer. While it's not entirely consistent, any output EML greater than 90kb has a strong chance of being truncated in this way.

    It appears to be a limit on the SQLite dataset. If I run the following query against the SQLite offline database I get several 38 hits and I have 42 EML files 90kb and higher.

    select * from MessagesFT_content where c0Subject like 'Chat with%' and c1Body like "%View Entire Message%";

    ReplyDelete
  4. Thanks. I was concerned after seeing a comment on CandorZ's forum, but I've since confirmed that none of my chats were clipped. My guess is that Offline Sync has a per-item size limitation. I don't think I did anything to workaround the limitation, so I guess I do not have very long chat sessions.

    Just to address other possible factors (I doubt these make a difference, but just in case), I exported from a Google Apps Standard account using offline sync in Windows 7 with Google Chrome (beta branch--hard to know exactly what version would have been installed at that time). Oh, and there's a setting in Gmail under "Offline" for attachment size--mine is at "All attachments." But again, that doesn't seem relevant.

    ReplyDelete
  5. Hi,
    That's a great guide, it helps me a lot with a project I'm working on. maybe you could help me with a further step - how can I export all the .eml files into a single text file, in a chronological order?
    thanks!

    ReplyDelete
  6. i was not able to find the path where my database has been stored....i could see my gmail, offline...but there was no application data only in my documents and settings...and so the whole path also doesnt exist as stated for firefox in windows xp. can you please help me out.

    ReplyDelete
  7. Sorry to hear that. I'm not sure what to tell you, other than that the file has to be on your computer somewhere. I can think of just a few things that will probably have already occurred to you if you're adventurous enough to try this out (but just in case): perhaps you need to change your folder options so that you can see hidden and/or system folders? Maybe look under a different user profile, or even the Public or All User folders?

    ReplyDelete
  8. Here's a note for the future. I discovered recently that Google Gears is no longer a part of Chrome, as of version 10 or 11 or so, meaning offline sync may be going the way of the ghost. This method should still be feasible for any browser that can still use offline sync, but I wouldn't be surprised if a year or two from now this doesn't work at all.

    ReplyDelete