Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Skype chatlog parser using Java and SQLJet
import java.io.File;
import java.util.Calendar;
import org.tmatesoft.sqljet.core.SqlJetException;
import org.tmatesoft.sqljet.core.SqlJetTransactionMode;
import org.tmatesoft.sqljet.core.table.ISqlJetCursor;
import org.tmatesoft.sqljet.core.table.ISqlJetTable;
import org.tmatesoft.sqljet.core.table.SqlJetDb;
public class SkypeChatLogParser {
public static void main(String[] args) throws SqlJetException {
SqlJetDb db = SqlJetDb.open(new File("main.db"), false);
db.beginTransaction(SqlJetTransactionMode.READ_ONLY);
ISqlJetTable table = db.getTable("Messages");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
long limit = calendar.getTime().getTime()/1000l;
System.out.println("<table>");
ISqlJetCursor crs = table.open();
while (crs.next()) {
String chatname = crs.getString(3);
String from_dispname = crs.getString(5);
long timestamp = crs.getInteger(9);
String body_xml = crs.getString(17);
if (timestamp > limit && chatname.contains("mychatname") ) {
System.out.println("<tr><td>"+from_dispname+"</td><td>"+body_xml+"</td></tr>");
}
}
System.out.println("</table>");
crs.close();
db.commit();
db.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment