Column depended randomization of csv-data
<p>I'm using a program called psychopy, it written in python, most of the time it has a GUI which is sufficient however you can input your own sections of code. Basically the problem i'm having is that I have a csv file which I get python to import, in the csv file there is six columns and with a bit of code I can get python to randomise the order in each column:</p>

<pre><code>import random 
import csv 

stimulilist=list(csv.reader(open('original_file.csv',"rU")))

stimuliones=[]
locationones=[]
locationtwos=[]
stimulitwos=[]
locationthrees[]
locationfours[]

for i in range(len(stimulilist)):
    stimuliones.append(stimulilist[i][0])
    locationones.append(stimulilist[i][1])
    locationtwos.append(stimulilist[i][2])
    stimulitwos.append(stimulilist[i][3])
    locationthrees.append(stimulilist[i][4])
    locationfours.append(stimulilist[i][5])

Stim1=stimuliones[1:]
location1=locationones[1:]
location2=locationtwos[1:]
Stim2=stimuliones[1:]
location3=locationthrees[1:]
location4=positionfours[1:]
</code></pre>

<p>Then I randomize them, this will create my two randomized word lists for the first block of trials.</p>

<pre><code>Stimuli1Random=random.sample(Stim1,len(Stim1)) 
Location1Random=random.sample(location1,len(location1))
Location2Random=random.sample(location2,len(location2))
Stimuli2Random=random.sample(Stim2,len(Stim2))
Location3random=random.sample(location3,len(location3))
Location4random=random.sample(location4,len(location4))
</code></pre>

<p>However, I want stimuli 1, location 1 and location 2 to be randomised together and stimuli 2 location 3 and location 4 to be randomised together for example:</p>

<p>How it is in CSV File:</p>

<pre><code>(row)    Stim1 Location1 Location2         (row)     Stim2 Location3 Location4
1        P1    Left      Left               1        c1    Left      Left
2        p2    Middle    Middle             2        c2    Middle    Middle
3        p3    Right     Right              3        c3    Right     Right
4        p4    Left      Left               4        c4    Left      Left
5        p5    Middle    Middle             5        c5    Middle    Middle
6        p6    Right     Right              6        c6    Right     Right
</code></pre>

<p>With the code above each column gets randomised individually e.g.:</p>

<pre><code>(row)    Stim1 Location1 Location2         (row)   Stim2  Location3 Location4
1        P6    Left      Middle             1      c5     Right     Left
2        p1    Right     Middle             2      c3     Middle    Middle
3        p5    Middle    Right              3      c1     Left      Middle
4        p4    Left      Left               4      c2     Right     Left
5        p3    Middle    Left               5      c4     Middle    Right
6        p2    Right     Right              6      c6     Left      Right
</code></pre>

<p>But I want the rows to be randomised so that it looks something like this:</p>

<pre><code>(row)    Stim1 Location1 Location2       (row)  Stim2  Location3 Location4
1        p2    Middle    Middle           1     c3      Right   Right
2        p6    Right     Right            2     c5      Middle  Middle
3        p3    Right     Right            3     c4      Left    Left
4        p4    Left      Left             4     c1      Left    Left
5        p5    Middle    Middle           5     c2      Middle  Middle
6        P1    Left      Left             6     c6      Right   Right
</code></pre>

<p>So basically I want the rows for Stim1, Location 1 and Location 2 to stay the same but be randomised as if they were the same column, however, I do not want to merge them to one column, its important they stay individual columns. I also want this for stim2 location 3 and location 4. </p>

<p>Additionally, say I wanted to import another column from the csv file, but not randomise it, how would I put that into the code?</p>
