Esempio n. 1
0
 def test_read_write_csv_dialect(self):
     expected = [['this is some text', 'scandal', '42'],
                 ["here's some more text: boom!", 'escándalo', '1.0']]
     filename = os.path.join(
         self.tempdir, 'test_read_write_csv.csv')
     fileio.write_csv(
         expected, filename, dialect='excel', auto_make_dirs=True)
     observed = list(fileio.read_csv(filename, dialect='infer'))
     self.assertEqual(observed, expected)
Esempio n. 2
0
 def test_read_write_csv_dialect(self):
     expected = [['this is some text', 'scandal', '42'],
                 ["here's some more text: boom!", 'escándalo', '1.0']]
     filename = os.path.join(
         self.tempdir, 'test_read_write_csv.csv')
     fileio.write_csv(
         expected, filename, dialect='excel', auto_make_dirs=True)
     observed = list(fileio.read_csv(filename, dialect='infer'))
     self.assertEqual(observed, expected)
Esempio n. 3
0
 def test_read_write_csv_delimiters(self):
     expected = [['this is some text', 'scandal', '42'],
                 ["here's some more text: boom!", 'escándalo', '1.0']]
     for delimiter in (',', '\t', '|', ':'):
         filename = os.path.join(
             self.tempdir, 'test_read_write_csv.csv')
         fileio.write_csv(
             expected, filename, delimiter=delimiter, auto_make_dirs=True)
         observed = list(fileio.read_csv(filename, delimiter=delimiter))
         self.assertEqual(observed, expected)
Esempio n. 4
0
 def test_read_write_csv_delimiters(self):
     expected = [['this is some text', 'scandal', '42'],
                 ["here's some more text: boom!", 'escándalo', '1.0']]
     for delimiter in (',', '\t', '|', ':'):
         filename = os.path.join(
             self.tempdir, 'test_read_write_csv.csv')
         fileio.write_csv(
             expected, filename, delimiter=delimiter, auto_make_dirs=True)
         observed = list(fileio.read_csv(filename, delimiter=delimiter))
         self.assertEqual(observed, expected)
Esempio n. 5
0
 def test_read_write_csv_compressed(self):
     expected = [['this is some text', 'scandal', '42'],
                 ["here's some more text: boom!", 'escándalo', '1.0']]
     for ext in ('.csv', '.csv.gz', '.csv.bz2', '.csv.xz'):
         filename = os.path.join(self.tempdir, 'test_read_write_csv' + ext)
         if is_python2 is True and ext != '.csv':
             self.assertRaises(ValueError, fileio.open_sesame, filename,
                               'wt', None, True)
         else:
             fileio.write_csv(expected, filename, auto_make_dirs=True)
             observed = list(fileio.read_csv(filename))
             self.assertEqual(observed, expected)
Esempio n. 6
0
 def test_read_write_csv_compressed(self):
     expected = [['this is some text', 'scandal', '42'],
                 ["here's some more text: boom!", 'escándalo', '1.0']]
     for ext in ('.csv', '.csv.gz', '.csv.bz2', '.csv.xz'):
         filename = os.path.join(
             self.tempdir, 'test_read_write_csv' + ext)
         if PY2 is True and ext != '.csv':
             self.assertRaises(
                 ValueError, fileio.open_sesame,
                 filename, 'wt', None, True)
         else:
             fileio.write_csv(expected, filename, auto_make_dirs=True)
             observed = list(fileio.read_csv(filename))
             self.assertEqual(observed, expected)