Two Plus Two Older Archives  

Go Back   Two Plus Two Older Archives > General Poker Discussion > Books and Publications
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2004, 01:41 AM
bobdibble bobdibble is offline
Member
 
Join Date: Jun 2004
Location: The Muck
Posts: 86
Default Pokertracker to statking export utility

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 />
Reply With Quote
  #2  
Old 10-08-2004, 05:04 PM
TexBigSlick TexBigSlick is offline
Junior Member
 
Join Date: Aug 2004
Posts: 2
Default Re: Pokertracker to statking export utility

Will this work for Ring Games and Tournaments?

Thanks
Reply With Quote
  #3  
Old 11-03-2004, 02:59 AM
bobdibble bobdibble is offline
Member
 
Join Date: Jun 2004
Location: The Muck
Posts: 86
Default Re: Pokertracker to statking export utility

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
Reply With Quote
  #4  
Old 11-03-2004, 03:06 AM
bobdibble bobdibble is offline
Member
 
Join Date: Jun 2004
Location: The Muck
Posts: 86
Default Re: Pokertracker to statking export utility

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.)
Reply With Quote
  #5  
Old 11-03-2004, 12:20 PM
sammy_g sammy_g is offline
Junior Member
 
Join Date: Apr 2004
Posts: 0
Default Re: Pokertracker to statking export utility

[ 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!
Reply With Quote
  #6  
Old 01-01-2005, 11:43 PM
Luv2DriveTT Luv2DriveTT is offline
Junior Member
 
Join Date: Apr 2004
Location: USA
Posts: 3
Default Re: Pokertracker to statking export utility

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]
Reply With Quote
  #7  
Old 01-02-2005, 12:35 AM
richie richie is offline
Senior Member
 
Join Date: Sep 2002
Location: the desert
Posts: 248
Default Re: Pokertracker to statking export utility

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]
Reply With Quote
  #8  
Old 01-02-2005, 09:23 AM
Luv2DriveTT Luv2DriveTT is offline
Junior Member
 
Join Date: Apr 2004
Location: USA
Posts: 3
Default Re: Pokertracker to statking export utility

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]
Reply With Quote
  #9  
Old 01-02-2005, 01:25 PM
richie richie is offline
Senior Member
 
Join Date: Sep 2002
Location: the desert
Posts: 248
Default Re: Pokertracker to statking export utility

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]
Reply With Quote
  #10  
Old 01-02-2005, 03:56 PM
richie richie is offline
Senior Member
 
Join Date: Sep 2002
Location: the desert
Posts: 248
Default Re: Pokertracker to statking export utility

This program worked great; quite a timesaver. Thanks for sharing this! [img]/images/graemlins/smile.gif[/img]
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.