T
- The type of the output generated.public class CSVLoader<T extends Output<T>> extends Object
The delimiter and quote characters are user controlled, so this class can parse TSVs, CSVs, semi-colon separated data and other types of single character delimiter separated data.
This class is a simple loader *only* for numerical CSV files with a String response field.
If you need more complex processing, the response field isn't present, or you don't wish to
use all of the columns as features then you should use CSVDataSource
and build a
RowProcessor
to cope with your specific input format.
CSVLoader is thread safe and immutable.
Modifier and Type | Class and Description |
---|---|
static class |
CSVLoader.CSVLoaderProvenance
Provenance for CSVs loaded by
CSVLoader . |
Constructor and Description |
---|
CSVLoader(char separator,
char quote,
OutputFactory<T> outputFactory)
Creates a CSVLoader using the supplied separator, quote and output factory.
|
CSVLoader(char separator,
OutputFactory<T> outputFactory)
Creates a CSVLoader using the supplied separator and output factory.
|
CSVLoader(OutputFactory<T> outputFactory)
Creates a CSVLoader using the supplied output factory.
|
Modifier and Type | Method and Description |
---|---|
MutableDataset<T> |
load(Path csvPath,
Set<String> responseNames)
Loads a DataSource from the specified csv file then wraps it in a dataset.
|
MutableDataset<T> |
load(Path csvPath,
Set<String> responseNames,
String[] header)
Loads a DataSource from the specified csv file then wraps it in a dataset.
|
MutableDataset<T> |
load(Path csvPath,
String responseName)
Loads a DataSource from the specified csv file then wraps it in a dataset.
|
MutableDataset<T> |
load(Path csvPath,
String responseName,
String[] header)
Loads a DataSource from the specified csv file then wraps it in a dataset.
|
ListDataSource<T> |
loadDataSource(Path csvPath,
Set<String> responseNames)
Loads a DataSource from the specified csv path.
|
ListDataSource<T> |
loadDataSource(Path csvPath,
Set<String> responseNames,
String[] header)
Loads a DataSource from the specified csv path.
|
ListDataSource<T> |
loadDataSource(Path csvPath,
String responseName)
Loads a DataSource from the specified csv path.
|
ListDataSource<T> |
loadDataSource(Path csvPath,
String responseName,
String[] header)
Loads a DataSource from the specified csv path.
|
ListDataSource<T> |
loadDataSource(URL csvPath,
Set<String> responseNames)
Loads a DataSource from the specified csv path.
|
ListDataSource<T> |
loadDataSource(URL csvPath,
Set<String> responseNames,
String[] header)
Loads a DataSource from the specified csv path.
|
ListDataSource<T> |
loadDataSource(URL csvPath,
String responseName)
Loads a DataSource from the specified csv path.
|
ListDataSource<T> |
loadDataSource(URL csvPath,
String responseName,
String[] header)
Loads a DataSource from the specified csv path.
|
public CSVLoader(char separator, char quote, OutputFactory<T> outputFactory)
separator
- The separator character.quote
- The quote character.outputFactory
- The output factory.public CSVLoader(char separator, OutputFactory<T> outputFactory)
CSVIterator.QUOTE
.separator
- The separator character.outputFactory
- The output factory.public CSVLoader(OutputFactory<T> outputFactory)
CSVIterator.SEPARATOR
and the quote to CSVIterator.QUOTE
.outputFactory
- The output factory.public MutableDataset<T> load(Path csvPath, String responseName) throws IOException
csvPath
- The path to load.responseName
- The name of the response variable.IOException
- If the read failed.public MutableDataset<T> load(Path csvPath, String responseName, String[] header) throws IOException
csvPath
- The path to load.responseName
- The name of the response variable.header
- The header of the CSV if it's not present in the file.IOException
- If the read failed.public MutableDataset<T> load(Path csvPath, Set<String> responseNames) throws IOException
csvPath
- The path to load.responseNames
- The names of the response variables.IOException
- If the read failed.public MutableDataset<T> load(Path csvPath, Set<String> responseNames, String[] header) throws IOException
csvPath
- The path to load.responseNames
- The names of the response variables.header
- The header of the CSV if it's not present in the file.IOException
- If the read failed.public ListDataSource<T> loadDataSource(Path csvPath, String responseName) throws IOException
csvPath
- The csv to load from.responseName
- The name of the response variable.IOException
- If the disk read failed.public ListDataSource<T> loadDataSource(URL csvPath, String responseName) throws IOException
csvPath
- The csv to load from.responseName
- The name of the response variable.IOException
- If the disk read failed.public ListDataSource<T> loadDataSource(Path csvPath, String responseName, String[] header) throws IOException
csvPath
- The csv to load from.responseName
- The name of the response variable.header
- The header of the CSV if it's not present in the file.IOException
- If the disk read failed.public ListDataSource<T> loadDataSource(URL csvPath, String responseName, String[] header) throws IOException
csvPath
- The csv to load from.responseName
- The name of the response variable.header
- The header of the CSV if it's not present in the file.IOException
- If the disk read failed.public ListDataSource<T> loadDataSource(Path csvPath, Set<String> responseNames) throws IOException
csvPath
- The csv to load from.responseNames
- The names of the response variables.IOException
- If the disk read failed.public ListDataSource<T> loadDataSource(URL csvPath, Set<String> responseNames) throws IOException
csvPath
- The csv to load from.responseNames
- The names of the response variables.IOException
- If the disk read failed.public ListDataSource<T> loadDataSource(Path csvPath, Set<String> responseNames, String[] header) throws IOException
csvPath
- The csv to load from.responseNames
- The names of the response variables.header
- The header of the CSV if it's not present in the file.IOException
- If the disk read failed.public ListDataSource<T> loadDataSource(URL csvPath, Set<String> responseNames, String[] header) throws IOException
csvPath
- The csv to load from.responseNames
- The names of the response variables.header
- The header of the CSV if it's not present in the file.IOException
- If the disk read failed.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.