Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

accessing information from the logfile

Dear forum,

is it possible to access the data in the logfile? (Data from a previous session)

I would like to run an experiment. In the beginning it should check whether there is a file in the logfile with a certain name (including ID and SessionNumber). Depeding on whether it is there or not, the session number will be altered.

In other words. The program shall check itself whether the participant has already performed lets say session 7, and therefore select 8 as the session number of the running experiment.

Any ideas on how to accomplish that?


  • Hi @DahmSF ,

    Yes, that's possible. To do that, you would need to write a simple script, like the one below, and add that to the Prepare phase of an inline_script at the start of the experiment. The script below checks whether a particular file, based on the subject number and session, already exists, and if so, increments the session number until the file doesn't exist yet. And then the file name is used to re-open the log.

    Hope that helps!


    import os
    MAX_SESSION = 10
    for var.session_nr in range(1, MAX_SESSION + 1):
        # Get the full path to the log file
        log_path = os.path.abspath(
            'logfile-{}-{}.csv'.format(var.subject_nr, var.session_nr)
        # If this log file doesn't exist yet, break the loop and use it
        if not os.path.exists(log_path):
        # Executed if no break occurred
        raise Exception('All session have been completed!')
    # Re-open the logfile

    Buy Me A Coffee

  • This is great stuff! Too good to be true 😀

    I just changed the directory of where the logfiles are stored to the directory of my experiment file.

    log_path = os.path.join(var.experiment_path,"Logfile", 'ID{}_Session{}.csv'.format(var.subject_nr, var.session_nr)




  • One more question on this:

    I always make a copy of the file at the end of the experiment. I used to take this code:


    However, the var.logfile seems to take the old file which is empty as the data is stored in the new file (see above). Is there a way to make a copy of the new file. I am pretty sure I need to use log_path somehow. Only that this is only the path but not the file itself.

    Thanks for your help


  • Hi Stephan,

    Thanks for pointing this out. Of course, should also update var.logfile , so that's a minor bug. (To be fixed for 3.3.5, because 3.3.4 was already tagged just now.) For now, this is easily worked around though:

    var.logfile = log_path



    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games