Howdy, Stranger!

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

Supported by

[open] Splitting list/file into smaller chunks

edited February 2015 in OpenSesame

Hi all,

I would appreciate some help with splitting a file into smaller parts. I´m still not that familiar with OpenSesame, so maybe this issue is rather simple to most of you...

I´ve got an item pool of overall 390 items and need to

  • shuffle the list (got that already)

  • split this item pool into two halves ("block1" and "block2", 195 each)

  • and then create various sublists for each half:

  • "study_list" items for each block, 100 items each (I need a "study_list_block1" and "study_list_block2", each containing the first 100 items of block1 or block2, respectively

  • distractor/lure items for each block, 50 items each (I need a list "distractors_block1" and "distractors_block2", each containing item 101-150 of the lists "block1" or "block2", respectively

  • buffer items for each block, items 151-170 of "block1" or "block2"

  • and finally the last 25 items, items 171-195, which need to be converted into anagrams later on

Since I need to call the lists throughout the experiment and the items shouldn´t mix up (e.g. some items shown twice, once in block1, once in block2), the lists should be created only once at the beginning and then stay as they are. So I might save the new lists somewhere in order to be able to call them whenever they´re needed later on. I don´t know if this is the best solution, maybe there´s another, easier approach?

As I said, I´ve already shuffled the main list and then tried to split it into two halves as follows:

def split_list(list_total):

half_list_total = len(list_total)/2

return list_total[:half_list_total], list_total[half_list_total:]

This seems to work for splitting the list into halves but not when I tried to draw specific items from the lists (e.g. studylist_b1 = list_b1_total[0:99].

Apart from that, I wanted to write out the newly created lists by "writelines" but this didn´t work either. Would this be the correct command at all?

I´d be really glad if someone could give me some hints :)
Thank you so much in advance!

Comments

  • edited February 2015

    Hi,

    In general, you seem to be almost there. Here, a few remarks:

    Since I need to call the lists throughout the experiment and the items shouldn´t mix up the lists should be created only once at the beginning and then stay as they are.

    In this case, it might be a better idea to save the final list as a tuple, in this way you make sure that it isn't changed by accident, while still being able to retrieve values just the way you would have done with lists.

    So I might save the new lists somewhere in order to be able to call them whenever they´re needed later on.

    Usually, this isn't necessary, because everything that you define in an inline_script will be available in every other inline_script in your experiment. Unless, you don't need the list anywhere else, you're fine. However, if you use some values of your lists in a sketchpad for example, you probably need to save it as instance of the experiment first. So simply exp.my_list = my_list. In doing so, you will be able to access it later as [my_list][index].

    This seems to work for splitting the list into halves but not when I tried to draw specific items from the lists (e.g. studylist_b1 = list_b1_total[0:99].

    I don't see why this shouldn't work. The code seems to be fine. Especially, if you consider, that you're basically repeating the exact same operation every time you create another subset of the list. The only thing that changes is the index.

    Apart from that, I wanted to write out the newly created lists by "writelines" but this didn´t work either. Would this be the correct command at all

    This depends on the content of your list. writelines expects a list of strings. If you're list doesn't hold strings in it, you'll have to use something else (e.g. pickles), or simple convert the lists' values first to strings (recommended).

    I hope this was of any help for you.

    Good luck,

    Eduard

    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 http://45.77.173.118/ 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