@@ -26,3 +26,44 @@ def test_csvReader(tmpdir):
26
26
assert out .outputs .column_0 == ["foo" , "bar" , "baz" ]
27
27
assert out .outputs .column_1 == ["hello" , "world" , "goodbye" ]
28
28
assert out .outputs .column_2 == ["300.1" , "5" , "0.3" ]
29
+
30
+
31
+ def test_csvReader_quoted (tmpdir ):
32
+ header = "files,labels,erosion\n "
33
+ lines = ['foo,"hello, world",300.1\n ' ]
34
+
35
+ name = tmpdir .join ("testfile.csv" ).strpath
36
+ with open (name , "w" ) as fid :
37
+ reader = utility .CSVReader ()
38
+ fid .writelines (lines )
39
+ fid .flush ()
40
+ reader .inputs .in_file = name
41
+ out = reader .run ()
42
+
43
+ assert out .outputs .column_0 == ["foo" ]
44
+ assert out .outputs .column_1 == ["hello, world" ]
45
+ assert out .outputs .column_2 == ["300.1" ]
46
+
47
+
48
+ def test_csvReader_tabs (tmpdir ):
49
+ header = "files\t labels\t erosion\n "
50
+ lines = ["foo\t hello\t 300.1\n " , "bar\t world\t 5\n " , "baz\t goodbye\t 0.3\n " ]
51
+ for x in range (2 ):
52
+ name = tmpdir .join ("testfile.csv" ).strpath
53
+ with open (name , "w" ) as fid :
54
+ reader = utility .CSVReader (delimiter = "\t " )
55
+ if x % 2 == 0 :
56
+ fid .write (header )
57
+ reader .inputs .header = True
58
+ fid .writelines (lines )
59
+ fid .flush ()
60
+ reader .inputs .in_file = name
61
+ out = reader .run ()
62
+ if x % 2 == 0 :
63
+ assert out .outputs .files == ["foo" , "bar" , "baz" ]
64
+ assert out .outputs .labels == ["hello" , "world" , "goodbye" ]
65
+ assert out .outputs .erosion == ["300.1" , "5" , "0.3" ]
66
+ else :
67
+ assert out .outputs .column_0 == ["foo" , "bar" , "baz" ]
68
+ assert out .outputs .column_1 == ["hello" , "world" , "goodbye" ]
69
+ assert out .outputs .column_2 == ["300.1" , "5" , "0.3" ]
0 commit comments