@@ -200,6 +200,26 @@ def test_csv_pandas_column_unsupported_data_types(self, tmp_path, noaa_jfk_schem
200
200
for t in (err_column .dtype , err_column .check ):
201
201
assert re .search (rf"{ t } (\d*|ing)\b" , str (e .value )) # "ing" is for "str'ing'"
202
202
203
+ def test_csv_pandas_no_delimiter (self , tmp_path , noaa_jfk_schema ):
204
+ "Test when no delimiter is given."
205
+ # Remove the delimiter option
206
+ del noaa_jfk_schema ['subdatasets' ]['jfk_weather_cleaned' ]['format' ]['options' ]['delimiter' ]
207
+ data = Dataset (noaa_jfk_schema , tmp_path ,
208
+ mode = Dataset .InitializationMode .DOWNLOAD_AND_LOAD ).data ['jfk_weather_cleaned' ]
209
+ assert len (data .columns ) == 16 # Number of columns remain the same
210
+
211
+ @pytest .mark .parametrize ('delimiter' , ('\t ' , ' ' , '|' , ';' ))
212
+ def test_csv_pandas_delimiter (self , tmp_path , noaa_jfk_schema , delimiter ):
213
+ "Test common delimiter settings. Note that the case of comma has been tested in ``test_csv_pandas_loader``."
214
+
215
+ del noaa_jfk_schema ['subdatasets' ]['jfk_weather_cleaned' ]['format' ]['options' ]['columns' ]
216
+ # Change delimiter to tab, |, ;, space
217
+ noaa_jfk_schema ['subdatasets' ]['jfk_weather_cleaned' ]['format' ]['options' ]['delimiter' ] = delimiter
218
+ data = Dataset (noaa_jfk_schema , tmp_path ,
219
+ mode = Dataset .InitializationMode .DOWNLOAD_AND_LOAD ).data ['jfk_weather_cleaned' ]
220
+ # None of these delimiters exist in the file, number of columns should be 1
221
+ assert len (data .columns ) == 1
222
+
203
223
def test_csv_pandas_loader_no_path (self ):
204
224
"Test CSVPandasLoader when fed in with non-path."
205
225
0 commit comments