Permalink
Browse files

BUG: open csvfile with newline='' on Python 3

  • Loading branch information...
1 parent 59a38a3 commit bac1e2c717947d1b10b543747d07351fa182b3b5 @cgohlke cgohlke committed Oct 16, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 la/deflarry.py
View
@@ -1,5 +1,7 @@
"Labeled array class"
+import sys
+
import csv
import numpy as np
@@ -4749,7 +4751,10 @@ def tocsv(self, filename, delimiter=','):
array([ 1., 2., 3.])
"""
- fid = open(filename, 'w')
+ if sys.version_info[0] < 3:
+ fid = open(filename, 'w')
+ else:
+ fid = open(filename, 'w', newline='')
writer = csv.writer(fid, delimiter=delimiter)
writer.writerows(self.totuples())
fid.close()

0 comments on commit bac1e2c

Please sign in to comment.