Open Side Menu Go to the Top
Register
Free script to Datamine UB Free script to Datamine UB

11-26-2008 , 06:38 PM
Okay. Here's the deal. This is a script written in python so if you want to use it you will need to go to www.python.org/download/ and download python. I used v2.6. If people don't want to/are unable to install python then I can probably make this available as a standalone executable. I chose to just give up the script since people are often (correctly) wary of running sketchy executables and this way people are free to modify/fix it when something inevitably doesn't work.

Instructions:

Make a new directory somewhere for the script. I used C:\Program Files\UBmine\ but it should work where ever you put it. Now create a new file in that folder called ub_mine.py and paste this code into it.

Code:
import os,shutil
import string
import time
from msvcrt import kbhit,getch

root_dir = os.getcwd()

#location of UB instant replay data files
replay_dir = "C:\Poker Application\UltimateBet\InstantReplay"

#move instant replay files to this directory after processing
converted_dir = root_dir+"/converted/"

#store the converted histories in this directory
hist_dir = root_dir+"/histories/"

#number of seconds to wait inbetween processing batches
sleep_time = 5

def main():

    os.chdir(replay_dir)

    #make directory to move processed hands to if it doesn't already exist
    if not os.path.isdir(converted_dir):
        try:
            os.mkdir(converted_dir)
        except:
            print "failed to make converted hand directory"
            raw_input("press any key to quit")
            exit()

    #make directory to store converted hand history file
    if not os.path.isdir(hist_dir):
        try:
            os.mkdir(hist_dir)
        except:
            print "failed to make hand history directory"
            raw_input("press any key to quit")
            exit()
            

    out_file = open(hist_dir+"converted.txt",'a')

    stop = False

    print "hit 'q' at any time to quit"

    while not stop:

        if kbhit() and getch() == 'q': stop = True
        
        dirList=os.listdir(os.getcwd())

        for fname in dirList:
            if fname.find('.dat')!=-1:
                if add_to_file(out_file,fname):
                    shutil.move(fname,converted_dir)

        time.sleep(sleep_time)
        out_file.flush()

    out_file.close()

def add_to_file(f,fname):
    try:
        infile = open(fname,'r')
        dat = infile.readlines()
        for i,line in enumerate(dat):
            dat[i] = dat[i].strip()
        infile.close()


        first = dat.index("[IHH]")
        dat = dat[first+1:len(dat)-1]
        hh = ''
        for line in dat:
            nxt_line = line.partition('=')[2]
            hh += nxt_line+'\n'
    
        f.write(hh)
    except:
        return False

    return True

if __name__ == '__main__': 
     main()
Now you should be able to double click on this file in explorer or right click and open or run it from a command line or whatever you like to do.

When you run the script it will open a command window that won't look like it's doing anything. You can now open up a bunch of ub tables and it will start saving hands to a file called converted.txt in %your prog dir%\histories\ e.g. for the directory I used above this would be C:\Program Files\UBmin\histories\

Now go add that directory to Holdem Managers auto import and you should be good to go.

I think that's all, but I probably forgot something/screwed something up so let me know if you can't get it running and I will do what I can to fix it or help you through it. Oh, you might have to run this as administrator in Vista and I haven't tested it on XP but it should work.

Sorry it isn't commented or anything but I just threw this together v. quickly.

p.m. me if you want to ship me some percentage of all the money this is going to help you make
Free script to Datamine UB Quote
11-27-2008 , 01:01 AM
sounds pretty cool..
i dont read code at all so forgive me for asking this, but can anyone confirm that this isnt gonna send my login to him or something lol
Free script to Datamine UB Quote
11-27-2008 , 01:13 AM
haha np. Hopefully someone else will confirm that it is legit for you.
Free script to Datamine UB Quote
11-27-2008 , 03:22 AM
(I think this is my first post here, so don't necessarily believe me)

This legit, haven't tested it, but its only reading the hand histories and not sending anything. Plus you have just inspired me to think about using python scripts for mining other poker sites...

Great work.
Free script to Datamine UB Quote
11-27-2008 , 10:15 AM
Just wanted to add that it is important you save the file with a ".py" extension as that is how windows knows to associated it with the python interpreter. It is also critical that you maintain the tab spacings the way they are in the file as whitespace is important in python scripts.

Also, you may need to tell windows to associate .py files with the python interpreter the first time you run a script. To do that right click on the ub_mine.py then go Open With->Choose Program->Browse then browse to C:\Python2x\python.exe

Last edited by Neko; 11-27-2008 at 10:27 AM. Reason: associate imo
Free script to Datamine UB Quote
11-27-2008 , 11:20 AM
Haven't run the script but reading through the code it looks all legit.
Free script to Datamine UB Quote
11-27-2008 , 12:05 PM
Hmm ... the cmd window opens and shuts immediately ....
Free script to Datamine UB Quote
11-27-2008 , 12:07 PM
Can you try this:
Quote:
try is to open up a command prompt. Change to the directory that the script is in and try to run it from the command line.
Start->Run
type cmd then enter.
change directories to where the script is e.g.
C:\ cd C:\Program Files\ub_mine <enter>
Then try running like so:
C:\ C:\Python26\python.exe ub_mine.py

and tell me what the error says.
Free script to Datamine UB Quote
11-27-2008 , 12:15 PM
Code:
C:\Program Files\UBmine>C:\Python26\python.exe ub_mine.py
Traceback (most recent call last):
  File "ub_mine.py", line 88, in <module>
    main()
  File "ub_mine.py", line 22, in main
    os.chdir(replay_dir)
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\Poker Application\\UltimateBet\\InstantReplay'

C:\Program Files\UBmine>

oh ... prob looking in wrong dir for UB
I will change the code for that ... hang on
Free script to Datamine UB Quote
11-27-2008 , 12:17 PM
yep .. changed in file to "Program Files" and works
cheers
Free script to Datamine UB Quote
11-27-2008 , 12:25 PM
Yep. Apparently on XP the directory is different. Sorry. Change:

Code:
#location of UB instant replay data files
replay_dir = "C:\Poker Application\UltimateBet\InstantReplay"
to

Code:
#location of UB instant replay data files
replay_dir = "C:\Program Files\UltimateBet\InstantReplay"
Free script to Datamine UB Quote
11-27-2008 , 12:31 PM
there is one difference betw hh files and the one this creates, which is that in the UB hh files, they put 3 empty lines before each new hand

not sure if that makes a diff or not ... should that be the case for observed hands also to be picked up?
Free script to Datamine UB Quote
11-27-2008 , 12:37 PM
HEM still imports them fine as far as I can tell. I can get rid of those lines if need be tho.
Free script to Datamine UB Quote
11-27-2008 , 12:44 PM
hmm ... seems to import them ... any idea at all why hem doesnt show the stats on the observed table tho?
Free script to Datamine UB Quote
11-27-2008 , 12:56 PM
not sure why the stats aren't showing now on observed tables. They were showing up for me yesterday. Not sure I can help with that though.

Glad you got it working though.
Free script to Datamine UB Quote
11-27-2008 , 01:07 PM
ok thanks man


Edit: it is working. dunno why wasn't initally.

Thanks man

I've always relied on the kindness of strangers =P
Oh ... that's not a "hooking up" line is it? I don't swing that way. Ok this is getting wierd, so I'm off.

Last edited by Pwoita; 11-27-2008 at 01:14 PM.
Free script to Datamine UB Quote
11-27-2008 , 03:23 PM
Neko,

do you have any bet pot AHK scripts that work for UB?
I read that the bet pot script that I use for Stars used to work on UB but I can't get it to work. ie. 3 times the BB plus one BB and post flop 2/3 and 3/4 pot bet

thanks,
Free script to Datamine UB Quote
11-27-2008 , 03:29 PM
No sorry I don't. The only bet pot functionality I used before was the scroll wheel and that is built into the software now.
Free script to Datamine UB Quote
11-27-2008 , 09:35 PM
Got this work for PT2 on XP...

too bad there is no working hud right now?


crap it ran for a while i opened like a bunch of tables and i keep getting errors every few minutes of running...


"line 88 in main()
shutil.move(fname,converted_dir)

file already exists?

if i delete the contents of the converted folder it runs for a few minutes and dies again..

Last edited by Jeff_B; 11-27-2008 at 09:53 PM.
Free script to Datamine UB Quote
11-27-2008 , 10:09 PM
Yea I get that too. It tries to write a new file but that filename exists.
Don't know how to fix it =/ Meaning I need to be watching the computer while it is datamining.
Sometimes it works for a long time ... other times it stops frequently. I guess the times it works for a long time, there is no filename clashes during that time.
Free script to Datamine UB Quote
11-28-2008 , 02:58 AM
Love your work mate. Really good stuff.
But unfortunately I am experiencing the same problem with the destination path of the moved file already existing. I don't know anything about Python, but id say the file needs to be appendaged onto the existing file, or the existing file needs to be deleted before moving or something like that. I've had a bit of a bash, but its just made it clearer that I have no idea what I'm doing. If you could find it in your heart to have a look at it, I'm sure you'd make a lot of us very happy
Cheers
Free script to Datamine UB Quote
11-28-2008 , 08:02 AM
I had some time and added a fix to it
Works nicely now


Code:
import os,shutil
import string
import time
from msvcrt import kbhit,getch

root_dir = os.getcwd()

#location of UB instant replay data files
replay_dir = "C:\Program Files\UltimateBet\InstantReplay"

#move instant replay files to this directory after processing
converted_dir = root_dir+"/converted/"

#store the converted histories in this directory
hist_dir = root_dir+"/histories/"

#number of seconds to wait inbetween processing batches
sleep_time = 5

def main():

    os.chdir(replay_dir)

    #make directory to move processed hands to if it doesn't already exist
    if not os.path.isdir(converted_dir):
        try:
            os.mkdir(converted_dir)
        except:
            print "failed to make converted hand directory"
            raw_input("press any key to quit")
            exit()

    #make directory to store converted hand history file
    if not os.path.isdir(hist_dir):
        try:
            os.mkdir(hist_dir)
        except:
            print "failed to make hand history directory"
            raw_input("press any key to quit")
            exit()
            

    out_file = open(hist_dir+"converted.txt",'a')

    stop = False

    print "hit 'q' at any time to quit"

    while not stop:

        if kbhit() and getch() == 'q': stop = True
        
        dirList=os.listdir(os.getcwd())

        for fname in dirList:
            if fname.find('.dat')!=-1:
                if add_to_file(out_file,fname):

                    # removing duplicate file if file exists
                    pathToFile = converted_dir+fname
                    if os.path.exists(pathToFile):
                        os.remove(pathToFile)

                    shutil.move(fname,converted_dir)
        time.sleep(sleep_time)
        out_file.flush()

    out_file.close()

def add_to_file(f,fname):
    try:
        infile = open(fname,'r')
        dat = infile.readlines()
        for i,line in enumerate(dat):
            dat[i] = dat[i].strip()
        infile.close()


        first = dat.index("[IHH]")
        dat = dat[first+1:len(dat)-1]
        hh = ''

        for line in dat:
            nxt_line = line.partition('=')[2]
            hh += nxt_line+'\n'
    
        hh += '\n\n\n'
        f.write(hh)

    except:
        return False

    return True

if __name__ == '__main__': 
     main()
Free script to Datamine UB Quote
11-28-2008 , 10:29 AM
thanks for that fix. Looks good to me. I guess sometimes it was moving the file before UB finished writing to it, so UB was creating a new one with the same name which caused the conflict.
Free script to Datamine UB Quote
11-28-2008 , 04:30 PM
I'm using the last code posted here and have changed the directory name in the code for use with vista.

What am I missing to get this working. When I double click the .py file the cmd prompt comes up briefly and then disappears and there's not sign of anything going on. The 'histories' folder has never been created.

Probably something I'm overlook having to do with Vista. Any ideas?

Thanks,

Bill
Free script to Datamine UB Quote
11-28-2008 , 04:31 PM
fwiw i downloaded python 30
Free script to Datamine UB Quote

      
m