bobdibble
10-05-2004, 01:41 AM
Cut/paste the following into a .vbs file.. e.g. call it pt2sk.vbs (You must have it end with .vbs, make sure that you didn't create a file called pt2sk.vbs.txt or some such nonsense.)
Then, I would suggest changing the line that has '"DEFAULT_PLAYER = "bobdibble"' to your own name in pokertracker.
To do the export, just run pt2sk.vbs.
You can call it with a specific player name from the command line if you wish. Just run the program with /? or /help for options.
It will create a statking importable file directly in your statking directory. Run statking, select import, and then select the pt.cvs file right from that directory.
I may do some direct to excel graphing too. If anyone wants to build up on this, feel free. I've been using this personally for a few months, and figure that even the basic statking export may be useful for others as it saves a few manual steps from the perl version.
p.s. It looks like the board is removing some of the whitespace.. not that it matters, but the original isn't all jammed on top of itself like this... it will still work though.
<font class="small">Code:</font><hr /><pre>
'************************************************* ****************************
'
' pt2sk.vbs
'
' Poker Tracker to StatKing session converter
'
' Author:
' BobDibble
'
' Version:
' 0.02
'
'************************************************* ****************************
'************************************************* ****************************
'
' Default command line values
'
'************************************************* ****************************
Const DEFAULT_PATH = "C:\Program Files\Poker Tracker V2"
Const DEFAULT_OUT_FILE = "c:\Program Files\StatKing\pt.csv"
Const DEFAULT_PLAYER = "bobdibble"
'************************************************* ****************************
'
' Main
'
'************************************************* ****************************
Set fs = CreateObject("Scripting.FileSystemObject")
GetOptions playerId, ptDb, outFileName, silent
Set outFile = fs.CreateTextFile(outFileName, True)
PokerTrackerToStatKing playerId, ptDb, outFile
'************************************************* ****************************
'
' Usage info
'
'************************************************* ****************************
Function Usage
Wscript.echo( _
"usage: /player:<name> [/path:<pt-path>] " _
& "[/out:<file-name>] [/silent]" & vbCrLf _
& " defaults: " & vbCrLf _
& " /path: " & DEFAULT_PATH & vbCrLf _
& " /out: " & DEFAULT_OUT_FILE)
Wscript.Quit
End Function
'************************************************* ****************************
'
' Get/validate command line options
'
'************************************************* ****************************
Function GetOptions(playerId, ptPath, outFileName, silent)
playerId = Wscript.Arguments.Named("player")
ptPath = Wscript.Arguments.Named("path")
outFileName = Wscript.Arguments.Named("out")
silent = Wscript.Arguments.Named.Exists("silent")
help = Wscript.Arguments.Named.Exists("help")
If not help Then
help = Wscript.Arguments.Named.Exists("?")
End If
If help Then
Usage()
End If
If playerId = "" Then
playerId = DEFAULT_PLAYER
End If
If ptPath = "" Then
ptPath = DEFAULT_PATH
End If
If outFileName = "" Then
outFileName = DEFAULT_OUT_FILE
End If
ptDb = ptPath & "\ptrack.mdb"
If Not fs.FileExists(ptPath) Then
Wscript.Echo(ptDb & " does not exist. " _
& "Rerun the script with a different /path: option")
Wscript.Quit
End If
End Function
'************************************************* ****************************
'
' Setup the DB connection and perform the querry to fetch the session data
'
'************************************************* ****************************
Function PokerTrackerToStatKing(playerId, ptDb, outFile)
num = 0
Set conn = Wscript.CreateObject("ADODB.Connection")
conn.Open("Driver={Microsoft Access Driver (*.mdb)};Dbq=" & _
ptDb & ";Uid=Admin;Pwd=;")
If Not Conn.State = 1 Then
Wscript.echo("could not open connection to db " & conn.state)
Wscript.Quit
End If
sqlText = "SELECT * " _
& "FROM session, players, poker_sites, game_level " _
& "WHERE session.player_id = players.player_id " _
& "AND players.screen_name = '" & playerId & "'" _
& "AND poker_sites.site_id = session.site_id " _
& "AND game_level.game_level_id = session.game_level_id"
Set rs = CreateObject("ADODB.Recordset")
rs.Open sqlText, conn, 0, 1
Do Until rs.EOF
outFile.WriteLine(FormatStatKing(rs))
rs.MoveNext
num = num + 1
Loop
If Not silent Then
Wscript.Echo("Exported " & num & " records for " & playerId)
End If
End Function
'************************************************* ****************************
'
' Format a pokertracker session querry record to StatKing format
'
'************************************************* ****************************
Function FormatStatKing(rs)
length = DateDiff("n", rs("session_start"), rs("session_end")) / 60
If length = 0 Then
length = 0.01
End If
amtWon = rs("amount_won")
exRate = rs("exrate")
If exRate > 0 Then
amtWon = amtWon * (1 / exRate)
End If
FormatStatKing = FormatStatKingTime(rs("session_start")) & "," _
& rs("site_name") & "," _
& Replace(rs("game_level_desc"), "$", "") & "," _
& FormatNumber(length, 15) & "," _
& FormatNumber(amtWon, 4)
End Function
'************************************************* ****************************
'
' Format a timeval into StatKing format
'
'************************************************* ****************************
Function FormatStatKingTime(time)
FormatStatKingTime = FormatDateTime(time, vbShortDate) & " " _
& FormatDateTime(time, vbShortTime) & ":" _
& Second(time)
End Function
</pre><hr />
Then, I would suggest changing the line that has '"DEFAULT_PLAYER = "bobdibble"' to your own name in pokertracker.
To do the export, just run pt2sk.vbs.
You can call it with a specific player name from the command line if you wish. Just run the program with /? or /help for options.
It will create a statking importable file directly in your statking directory. Run statking, select import, and then select the pt.cvs file right from that directory.
I may do some direct to excel graphing too. If anyone wants to build up on this, feel free. I've been using this personally for a few months, and figure that even the basic statking export may be useful for others as it saves a few manual steps from the perl version.
p.s. It looks like the board is removing some of the whitespace.. not that it matters, but the original isn't all jammed on top of itself like this... it will still work though.
<font class="small">Code:</font><hr /><pre>
'************************************************* ****************************
'
' pt2sk.vbs
'
' Poker Tracker to StatKing session converter
'
' Author:
' BobDibble
'
' Version:
' 0.02
'
'************************************************* ****************************
'************************************************* ****************************
'
' Default command line values
'
'************************************************* ****************************
Const DEFAULT_PATH = "C:\Program Files\Poker Tracker V2"
Const DEFAULT_OUT_FILE = "c:\Program Files\StatKing\pt.csv"
Const DEFAULT_PLAYER = "bobdibble"
'************************************************* ****************************
'
' Main
'
'************************************************* ****************************
Set fs = CreateObject("Scripting.FileSystemObject")
GetOptions playerId, ptDb, outFileName, silent
Set outFile = fs.CreateTextFile(outFileName, True)
PokerTrackerToStatKing playerId, ptDb, outFile
'************************************************* ****************************
'
' Usage info
'
'************************************************* ****************************
Function Usage
Wscript.echo( _
"usage: /player:<name> [/path:<pt-path>] " _
& "[/out:<file-name>] [/silent]" & vbCrLf _
& " defaults: " & vbCrLf _
& " /path: " & DEFAULT_PATH & vbCrLf _
& " /out: " & DEFAULT_OUT_FILE)
Wscript.Quit
End Function
'************************************************* ****************************
'
' Get/validate command line options
'
'************************************************* ****************************
Function GetOptions(playerId, ptPath, outFileName, silent)
playerId = Wscript.Arguments.Named("player")
ptPath = Wscript.Arguments.Named("path")
outFileName = Wscript.Arguments.Named("out")
silent = Wscript.Arguments.Named.Exists("silent")
help = Wscript.Arguments.Named.Exists("help")
If not help Then
help = Wscript.Arguments.Named.Exists("?")
End If
If help Then
Usage()
End If
If playerId = "" Then
playerId = DEFAULT_PLAYER
End If
If ptPath = "" Then
ptPath = DEFAULT_PATH
End If
If outFileName = "" Then
outFileName = DEFAULT_OUT_FILE
End If
ptDb = ptPath & "\ptrack.mdb"
If Not fs.FileExists(ptPath) Then
Wscript.Echo(ptDb & " does not exist. " _
& "Rerun the script with a different /path: option")
Wscript.Quit
End If
End Function
'************************************************* ****************************
'
' Setup the DB connection and perform the querry to fetch the session data
'
'************************************************* ****************************
Function PokerTrackerToStatKing(playerId, ptDb, outFile)
num = 0
Set conn = Wscript.CreateObject("ADODB.Connection")
conn.Open("Driver={Microsoft Access Driver (*.mdb)};Dbq=" & _
ptDb & ";Uid=Admin;Pwd=;")
If Not Conn.State = 1 Then
Wscript.echo("could not open connection to db " & conn.state)
Wscript.Quit
End If
sqlText = "SELECT * " _
& "FROM session, players, poker_sites, game_level " _
& "WHERE session.player_id = players.player_id " _
& "AND players.screen_name = '" & playerId & "'" _
& "AND poker_sites.site_id = session.site_id " _
& "AND game_level.game_level_id = session.game_level_id"
Set rs = CreateObject("ADODB.Recordset")
rs.Open sqlText, conn, 0, 1
Do Until rs.EOF
outFile.WriteLine(FormatStatKing(rs))
rs.MoveNext
num = num + 1
Loop
If Not silent Then
Wscript.Echo("Exported " & num & " records for " & playerId)
End If
End Function
'************************************************* ****************************
'
' Format a pokertracker session querry record to StatKing format
'
'************************************************* ****************************
Function FormatStatKing(rs)
length = DateDiff("n", rs("session_start"), rs("session_end")) / 60
If length = 0 Then
length = 0.01
End If
amtWon = rs("amount_won")
exRate = rs("exrate")
If exRate > 0 Then
amtWon = amtWon * (1 / exRate)
End If
FormatStatKing = FormatStatKingTime(rs("session_start")) & "," _
& rs("site_name") & "," _
& Replace(rs("game_level_desc"), "$", "") & "," _
& FormatNumber(length, 15) & "," _
& FormatNumber(amtWon, 4)
End Function
'************************************************* ****************************
'
' Format a timeval into StatKing format
'
'************************************************* ****************************
Function FormatStatKingTime(time)
FormatStatKingTime = FormatDateTime(time, vbShortDate) & " " _
& FormatDateTime(time, vbShortTime) & ":" _
& Second(time)
End Function
</pre><hr />