Created
September 12, 2015 11:31
-
-
Save rhulha/7154dfe3ad270e6f7282 to your computer and use it in GitHub Desktop.
Skype chatlog parser using Java and SQLJet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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