def test_read_header(self): col_names = ["Strings", "Longs", "Floats"] col_types = [dtypes.string, dtypes.long, dtypes.float_] table_header = {k: v for k, v in zip(col_names, col_types)} t = read_csv('tests/data/test_csv.csv', header=table_header) t_col_names = [col.name for col in t.columns] self.assertEqual(col_names, t_col_names)
def test_write(self): t = read_csv("tests/data/small_sample.csv") write_csv(t, "./test_write.csv") t_cols = [col.name for col in t.columns] t = read_csv("./test_write.csv") self.assertEqual(t_cols, [col.name for col in t.columns]) col_names = ["Strings", "Longs", "Floats"] col_types = [dtypes.string, dtypes.long, dtypes.float_] table_header = {k: v for k, v in zip(col_names, col_types)} t = read_csv('tests/data/test_csv.csv', header=table_header) write_csv(t, "./test_write.csv", cols=col_names) t = read_csv('./test_write.csv') self.assertEqual(col_names, [c.name for c in t.columns]) import os os.remove("./test_write.csv")
def test_read_error_col_type(self): col_names = ["Strings", "Longs", "Floats"] col_types = [dtypes.string, dtypes.float_, dtypes.long] table_header = {k: v for k, v in zip(col_names, col_types)} with self.assertRaises(DHError) as cm: t = read_csv('tests/data/test_csv.csv', header=table_header) self.assertIsNotNone(cm.exception.compact_traceback)
def test_read_simple(self): t = read_csv("tests/data/small_sample.csv") self.assertTrue(t.columns)
def setUp(self): self.test_table = read_csv("tests/data/test_table.csv")
def setUp(self): self.test_table = read_csv("tests/data/test_table.csv") self.partitioned_table = self.test_table.partition_by(by=["c", "e"])