Commits

Aleš Erjavec committed 4ba6adf

Open csv files in universal newline mode.

  • Participants
  • Parent commits 706aae4

Comments (0)

Files changed (2)

Orange/OrangeWidgets/Prototypes/OWCSVFileImport.py

 
         self.selected_file = filename
         self.selected_file_head = []
-        with open(self.selected_file, "rb") as f:
+        with open(self.selected_file, "rU") as f:
             for i, line in zip(range(30), f):
                 self.selected_file_head.append(line)
 
 def sniff_csv(file):
     snifer = csv.Sniffer()
     if isinstance(file, basestring):
-        file = open(file, "rb")
+        file = open(file, "rU")
 
     sample = file.read(2 ** 20)  # max 1MB sample
     dialect = snifer.sniff(sample)

Orange/data/io.py

     """ Load an Orange.data.Table from s csv file.
     """
     import csv, numpy
-    file = as_open_file(file, "rb")
+    file = as_open_file(file, "rU")
     snifer = csv.Sniffer()
 
     # Max 5MB sample