Storing all the contacts in my various address books and networks in one address book file in the FOAF format is part of my vision for organising my digital life better with Semantic Web technologies. I haven't tried Beatnik yet but it might help with that. This is also part of a plan to integrate semantic stuff a bit deeper into my Web site, ultimately showing that we don't need the walled gardens and data silos that are social network platforms today but more on that as soon as I've made some progress with my ideas.
For now we will just try to convert some contact data. I'm not member of many social network sites because I don't like them. I don't like giving them my data. So if I want to manage my social network myself using FOAF, where could I start getting my contacts from? Most of my friends use ICQ and so IM contacts would make for a good start. Fortunately the messenger I use, Miranda IM, can export all my contacts into an easy-to-handle .ini file. To do that you click on its menu, go to "contact list import/export", then "export contact list", confirm the warning, choose where to store the file and say you don't want to export your history.
This file is kept quite simple: for each contact you have a section with a number. In each section you have several attributes. The ones we will use are "ID", "CListNick", "CListGroup", "Proto" and "Hidden". Now we need something to parse the .ini file. I work with Java and used the ini4j library for that. With it we will read in the file and then have access to the sections and the attributes of a section as Java Maps. From there on we just open another file and write the RDF/XML we want to generate as plain text into it (note that we need our URI to relate other people to ourselves).
So, we go through the sections (contacts) and whenever we see one with the attribute "Hidden" we skip it (this is people who wanted to reach you or people you ignored I assume). We use the attribute "CListGroup" to create memberships to foaf:Groups. "CListNick" servers as the foaf:nick of a person. To be able to use "ID" as an identifier we first have to determine the appropriate property to put it into. Therefore we map the value in "Proto" (protocol) to the name of a FOAF attribute: "JABBER" to foaf:jabberID, "ICQ" to foaf:icqChatID and so on. After we finished writing out all the contacts we write the groups and then finish the file. That's it.
Now you have a valid FOAF file with your IM contact list data. This is not perfect yet - the people in it are uniquely identified by their IM IDs but they don't have URIs, neither have the groups we created. Also when you want to map those entries to people from other sources you probably have to do it manually. LiveJournal has IM IDs in their FOAF data but I don't think you can search for them so you could only do it if you already know the people's handles there you want to integrate into your address book.
Take a look at the Java file for more detail.

