![]() |
#1
|
|||
|
|||
![]()
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 /> |
#2
|
|||
|
|||
![]()
Will this work for Ring Games and Tournaments?
Thanks |
#3
|
|||
|
|||
![]()
reposting.. not in a code block.. formating is weird, but apparently you couldn't cut/paste the orignal correctly... the forum is stipping all the leading spaces, but oh well.
'************************************************* **************************** ' ' 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 |
#4
|
|||
|
|||
![]()
Tournaments are stored in a different table I think. I only just recetly played in any. I may look at adding tourney export in the next few weekends. (btw, I don't monitor this thread, so feel free to pm me about stuff.. apparently not too many people tried this out, but someone just recently pm'd me about a cut/paste problem.. had it not been for that pm, I wouldn't have seen this question.)
|
#5
|
|||
|
|||
![]()
[ QUOTE ]
Tournaments are stored in a different table I think. I only just recetly played in any. I may look at adding tourney export in the next few weekends. [/ QUOTE ] I am definitely interested in this support. Thanks for sharing these scripts! |
#6
|
|||
|
|||
![]()
Wow... I just discovered this post. FANTASTIC tool. I was using the pearl script, this is far more convenient. Thanks!
BUMP IT UP! VERY USEFUL! TT [img]/images/graemlins/club.gif[/img] |
#7
|
|||
|
|||
![]()
Ok, I am computer illiterate. I copied the post to Wordpad, but it wants to make it a text file. How do I make it a ".vbs" file? Also, do I need any other software to run this program? Thanks in advance, Rich [img]/images/graemlins/blush.gif[/img] [img]/images/graemlins/blush.gif[/img]
|
#8
|
|||
|
|||
![]()
VBS is a scripting sollution built right into all windows computers. Visual Basic Scripts are often viruses, so you may have to let you virus protection software know that its ok to run this script. Once you save the text file, change the .XXX extention from .TXT to .VBS. The icon will instantly change, and you are ready to run it!
TT [img]/images/graemlins/club.gif[/img] |
#9
|
|||
|
|||
![]()
Thanks. I had to figure out how to get the file extensions on my computer "unhidden". I went to the perl script thread and then to the link that showed me how to do this in folder options on my computer. Jumbled nonsense reply I know. [img]/images/graemlins/tongue.gif[/img]
|
#10
|
|||
|
|||
![]()
This program worked great; quite a timesaver. Thanks for sharing this! [img]/images/graemlins/smile.gif[/img]
|
![]() |
|
|