PDA

View Full Version : Pokertracker to statking export utility


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:&lt;name&gt; [/path:&lt;pt-path&gt;] " _
&amp; "[/out:&lt;file-name&gt;] [/silent]" &amp; vbCrLf _
&amp; " defaults: " &amp; vbCrLf _
&amp; " /path: " &amp; DEFAULT_PATH &amp; vbCrLf _
&amp; " /out: " &amp; 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 &amp; "\ptrack.mdb"

If Not fs.FileExists(ptPath) Then
Wscript.Echo(ptDb &amp; " does not exist. " _
&amp; "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=" &amp; _
ptDb &amp; ";Uid=Admin;Pwd=;")

If Not Conn.State = 1 Then
Wscript.echo("could not open connection to db " &amp; conn.state)
Wscript.Quit
End If

sqlText = "SELECT * " _
&amp; "FROM session, players, poker_sites, game_level " _
&amp; "WHERE session.player_id = players.player_id " _
&amp; "AND players.screen_name = '" &amp; playerId &amp; "'" _
&amp; "AND poker_sites.site_id = session.site_id " _
&amp; "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 " &amp; num &amp; " records for " &amp; 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 &gt; 0 Then
amtWon = amtWon * (1 / exRate)
End If

FormatStatKing = FormatStatKingTime(rs("session_start")) &amp; "," _
&amp; rs("site_name") &amp; "," _
&amp; Replace(rs("game_level_desc"), "$", "") &amp; "," _
&amp; FormatNumber(length, 15) &amp; "," _
&amp; FormatNumber(amtWon, 4)
End Function


'************************************************* ****************************
'
' Format a timeval into StatKing format
'
'************************************************* ****************************
Function FormatStatKingTime(time)
FormatStatKingTime = FormatDateTime(time, vbShortDate) &amp; " " _
&amp; FormatDateTime(time, vbShortTime) &amp; ":" _
&amp; Second(time)
End Function

</pre><hr />

TexBigSlick
10-08-2004, 05:04 PM
Will this work for Ring Games and Tournaments?

Thanks

bobdibble
11-03-2004, 02:59 AM
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:&lt;name&gt; [/path:&lt;pt-path&gt;] " _
&amp; "[/out:&lt;file-name&gt;] [/silent]" &amp; vbCrLf _
&amp; " defaults: " &amp; vbCrLf _
&amp; " /path: " &amp; DEFAULT_PATH &amp; vbCrLf _
&amp; " /out: " &amp; 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 &amp; "\ptrack.mdb"

If Not fs.FileExists(ptPath) Then
Wscript.Echo(ptDb &amp; " does not exist. " _
&amp; "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=" &amp; _
ptDb &amp; ";Uid=Admin;Pwd=;")

If Not Conn.State = 1 Then
Wscript.echo("could not open connection to db " &amp; conn.state)
Wscript.Quit
End If

sqlText = "SELECT * " _
&amp; "FROM session, players, poker_sites, game_level " _
&amp; "WHERE session.player_id = players.player_id " _
&amp; "AND players.screen_name = '" &amp; playerId &amp; "'" _
&amp; "AND poker_sites.site_id = session.site_id " _
&amp; "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 " &amp; num &amp; " records for " &amp; 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 &gt; 0 Then
amtWon = amtWon * (1 / exRate)
End If

FormatStatKing = FormatStatKingTime(rs("session_start")) &amp; "," _
&amp; rs("site_name") &amp; "," _
&amp; Replace(rs("game_level_desc"), "$", "") &amp; "," _
&amp; FormatNumber(length, 15) &amp; "," _
&amp; FormatNumber(amtWon, 4)
End Function


'************************************************* ****************************
'
' Format a timeval into StatKing format
'
'************************************************* ****************************
Function FormatStatKingTime(time)
FormatStatKingTime = FormatDateTime(time, vbShortDate) &amp; " " _
&amp; FormatDateTime(time, vbShortTime) &amp; ":" _
&amp; Second(time)
End Function

bobdibble
11-03-2004, 03:06 AM
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.)

sammy_g
11-03-2004, 12:20 PM
[ 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!

Luv2DriveTT
01-01-2005, 11:43 PM
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 /images/graemlins/club.gif

richie
01-02-2005, 12:35 AM
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 /images/graemlins/blush.gif /images/graemlins/blush.gif

Luv2DriveTT
01-02-2005, 09:23 AM
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 /images/graemlins/club.gif

richie
01-02-2005, 01:25 PM
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. /images/graemlins/tongue.gif

richie
01-02-2005, 03:56 PM
This program worked great; quite a timesaver. Thanks for sharing this! /images/graemlins/smile.gif

sthief09
01-17-2005, 10:27 AM
I was just linked to this, and I'm getting 0 records. I pasted it in, saved it as a .vbs, and double clicked, and 0 records. what am I doing wrong? Thanks.

Sheriff Fatman
01-17-2005, 12:01 PM
I've just tried it too and am getting some kind of error message when I run it.

All help appreciated.

Sheriff

balkii
01-17-2005, 11:10 PM
you have to manually edit the file to include your PT alias. also if you have more than 1 DB, you will have to edit the file to make sure it points to the correct DB

sthief09
01-18-2005, 05:23 AM
I see what I did wrong. I didn't change my db name. thanks

chipolino
02-10-2005, 02:47 PM
I got one word for you bobdibble: AWESOME!!!
Very very nice. No problems encountered on this end. Great job !!! /images/graemlins/smile.gif

bobbyi
02-10-2005, 03:40 PM
[ QUOTE ]
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. /images/graemlins/tongue.gif

[/ QUOTE ]
Yes, you can do this by switching file name hiding on and off so that you can take your .txt file and rename it to .vbs . However, there is an easier way. When you initially save it, if the filename you type into the save dialog in notepad/wordpad is "filename.vbs" (with the double quotes), it will save the file as filename.vbs rather than filename.txt. (You probably want to use a more meaningful name than filename, that's just an exmaple).

Luv2DriveTT
02-24-2005, 10:53 PM
bobdibble:

Your PT export tool has been a great addition to my tool kit. Now that the Omaha version of Poker Tracker has been released, can you make an alternate script to perform the same functions?

TT /images/graemlins/club.gif

royaltrux
02-24-2005, 11:23 PM
I get this when I try to run the pt2sk.vbs:

Windows Script Host

Script: C:\Program Files\Poker Tracker V2\pt2sk.vbs
Line: 1
Char: 1
Error: Invalid character
Code: 800A0408
Source: Microsoft VBScript compilation error

Any help would be appreciated.

Derek in NYC
03-21-2005, 11:37 PM
I get the same error when I try to run this file. Any clue as to what I did wrong?