Class | Test::Unit::Data::ClassMethods::Loader |
In: |
lib/test/unit/data.rb
|
Parent: | Object |
Load data from CSV file.
There are 2 types of CSV file as following examples. First, there is a header on first row and it‘s first column is "label". Another, there is no header in the file.
@example Load data from CSV file with header
# test-data.csv: # label,expected,target # empty string,true,"" # plain string,false,hello # load_data("/path/to/test-data.csv") def test_empty?(data) assert_equal(data["expected"], data["target"].empty?) end
@example Load data from CSV file without header
# test-data-without-header.csv: # empty string,true,"" # plain string,false,hello # load_data("/path/to/test-data-without-header.csv") def test_empty?(data) expected, target = data assert_equal(expected, target.empty?) end
@api private
Load data from TSV file.
There are 2 types of TSV file as following examples. First, there is a header on first row and it‘s first column is "label". Another, there is no header in the file.
@example Load data from TSV file with header
# test-data.tsv: # label expected target # empty string true "" # plain string false hello # load_data("/path/to/test-data.tsv") def test_empty?(data) assert_equal(data["expected"], data["target"].empty?) end
@example Load data from TSV file without header
# test-data-without-header.tsv: # empty string true "" # plain string false hello # load_data("/path/to/test-data-without-header.tsv") def test_empty?(data) expected, target = data assert_equal(expected, target.empty?) end
@api private