
import csv
import pprint

p = 0

# read schedule (from SCRT)
schedule_f = 'schedule_' + str(p)
inf = open(schedule_f,'r')
for line in inf.readlines():
    line = line.rstrip()
    schedule = line.split(' ')
inf.close()

# allocate stimuli
a = 0
b = []
phase = ''
for session in range(1,36):
    print "%s" % session
    blocks   = ''
    previous = phase
    phase    = schedule[session - 1]
    if phase == 'B':
        if phase != previous:
            transition = session % 10
            b          = [transition]
            repeat     = 0
        if repeat == 3:
            b.append((b[-1] + 1) % 10)
            repeat = 0
        a = (b[-1] + 1) % 10
        repeat += 1
    else:
        a = session % 10
    print ',' . join(map(str,b))
    print str(a)


import csv
import pprint

p = 0

# read schedule (from SCRT)
schedule_f = 'schedule_' + str(p)
inf = open(schedule_f,'r')
for line in inf.readlines():
    line = line.rstrip()
    schedule = line.split(' ')
inf.close()

# allocate stimuli and write csv
a       = 0
b       = []
phase   = ''
csvfile = open('stimuli_' + str(p) + '.csv', 'wb')
writer  = csv.writer(csvfile, delimiter=',')
for session in range(1,36):
    writer.writerow([session])
    blocks   = ''
    previous = phase
    phase    = schedule[session - 1]
    if phase == 'B':
        if phase != previous:
            transition = session % 10
            b          = [transition]
            repeat     = 0
        if repeat == 3:
            b.append((b[-1] + 1) % 10)
            repeat = 0
        a = (b[-1] + 1) % 10
        repeat += 1
    else:
        a = session % 10
    writer.writerow(b)
    writer.writerow([a])

Write stimuli schedule to csv file.
Write stimuli schedule to csv file.

  
  import csv
  import pprint
  
  p = 0
  
  # read schedule (from SCRT)
  schedule_f = 'schedule_' + str(p)
  inf = open(schedule_f,'r')
  for line in inf.readlines():
      line = line.rstrip()
      schedule = line.split(' ')
  inf.close()
  
- # allocate stimuli
- a = 0
- b = []
+ # allocate stimuli and write csv
+ a       = 0
+ b       = []
- phase = ''
+ phase   = ''
+ csvfile = open('stimuli_' + str(p) + '.csv', 'wb')
+ writer  = csv.writer(csvfile, delimiter=',')
  for session in range(1,36):
-     print "%s" % session
+     writer.writerow([session])
      blocks   = ''
      previous = phase
      phase    = schedule[session - 1]
      if phase == 'B':
          if phase != previous:
              transition = session % 10
              b          = [transition]
              repeat     = 0
          if repeat == 3:
              b.append((b[-1] + 1) % 10)
              repeat = 0
          a = (b[-1] + 1) % 10
          repeat += 1
      else:
          a = session % 10
-     print ',' . join(map(str,b))
-     print str(a)
+     writer.writerow(b)
+     writer.writerow([a])
  
Write stimuli schedule to csv file.
## Code Before:

import csv
import pprint

p = 0

# read schedule (from SCRT)
schedule_f = 'schedule_' + str(p)
inf = open(schedule_f,'r')
for line in inf.readlines():
    line = line.rstrip()
    schedule = line.split(' ')
inf.close()

# allocate stimuli
a = 0
b = []
phase = ''
for session in range(1,36):
    print "%s" % session
    blocks   = ''
    previous = phase
    phase    = schedule[session - 1]
    if phase == 'B':
        if phase != previous:
            transition = session % 10
            b          = [transition]
            repeat     = 0
        if repeat == 3:
            b.append((b[-1] + 1) % 10)
            repeat = 0
        a = (b[-1] + 1) % 10
        repeat += 1
    else:
        a = session % 10
    print ',' . join(map(str,b))
    print str(a)

## Instruction:
Write stimuli schedule to csv file.
## Code After:

import csv
import pprint

p = 0

# read schedule (from SCRT)
schedule_f = 'schedule_' + str(p)
inf = open(schedule_f,'r')
for line in inf.readlines():
    line = line.rstrip()
    schedule = line.split(' ')
inf.close()

# allocate stimuli and write csv
a       = 0
b       = []
phase   = ''
csvfile = open('stimuli_' + str(p) + '.csv', 'wb')
writer  = csv.writer(csvfile, delimiter=',')
for session in range(1,36):
    writer.writerow([session])
    blocks   = ''
    previous = phase
    phase    = schedule[session - 1]
    if phase == 'B':
        if phase != previous:
            transition = session % 10
            b          = [transition]
            repeat     = 0
        if repeat == 3:
            b.append((b[-1] + 1) % 10)
            repeat = 0
        a = (b[-1] + 1) % 10
        repeat += 1
    else:
        a = session % 10
    writer.writerow(b)
    writer.writerow([a])
