Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BF: manual fix for csv writing in example

Use manual fix for Python 2 / 3 differences for clarity in example.
  • Loading branch information...
commit 9a4a038d1805fe72aa77b86ce1ed58fc09fea0cb 1 parent 83a8082
@matthew-brett matthew-brett authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 examples/labs/write_paradigm_file.py
View
7 examples/labs/write_paradigm_file.py
@@ -7,6 +7,7 @@
See Pinel et al., BMC neuroscience 2007 for reference
"""
+import sys
import csv
import numpy as np
@@ -45,7 +46,11 @@
sess = np.zeros(np.size(time)).astype('int8')
pdata = np.vstack((sess, cid, time)).T
csvfile = 'localizer_paradigm.csv'
-fid = open(csvfile, "wt")
+# Opening files for CSV writing differs between Python 2 and 3
+if sys.version_info[0] >= 3: # Python 3
+ fid = open(csvfile, "w", newline = '')
+else: # Python 2
+ fid = open(csvfile, "wb")
writer = csv.writer(fid, delimiter=' ')
for row in pdata:
writer.writerow(row)
Please sign in to comment.
Something went wrong with that request. Please try again.