de.erichseifert.gral.io.data
Class CSVReader
- java.lang.Object
-
- de.erichseifert.gral.io.IOCapabilitiesStorage
-
- de.erichseifert.gral.io.data.AbstractDataReader
-
- de.erichseifert.gral.io.data.CSVReader
-
- All Implemented Interfaces:
- DataReader
public class CSVReader extends AbstractDataReader
Class that creates a
DataSourcefrom file contents which are separated by a certain delimiter character. The delimiter is chosen based on the file type but can also be set manually. By default the comma character will be used as a delimiter for separating columns.CSVReaderinstances should be obtained by theDataReaderFactoryrather than being created manually:DataReaderFactory factory = DataReaderFactory.getInstance(); DataReader reader = factory.get("text/csv"); reader.read(new FileInputStream(filename), Integer.class, Double.class);- See Also:
- RFC 4180
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringSEPARATOR_CHARKey for specifying aCharactervalue that defines the delimiting character used to separate columns.
-
Constructor Summary
Constructors Constructor and Description CSVReader(java.lang.String mimeType)Creates a new instance with the specified MIME type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description DataSourceread(java.io.InputStream input, java.lang.Class<? extends java.lang.Comparable<?>>... types)Returns a DataSource that was imported.-
Methods inherited from class de.erichseifert.gral.io.data.AbstractDataReader
getMimeType, getSetting, setSetting
-
Methods inherited from class de.erichseifert.gral.io.IOCapabilitiesStorage
getCapabilities
-
-
-
-
Field Detail
-
SEPARATOR_CHAR
public static final java.lang.String SEPARATOR_CHAR
Key for specifying aCharactervalue that defines the delimiting character used to separate columns.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CSVReader
public CSVReader(java.lang.String mimeType)
Creates a new instance with the specified MIME type. The delimiter is set depending on the MIME type parameter. By default a comma is used as a delimiter.- Parameters:
mimeType- MIME type of the file format to be read.
-
-
Method Detail
-
read
public DataSource read(java.io.InputStream input, java.lang.Class<? extends java.lang.Comparable<?>>... types) throws java.io.IOException
Returns a DataSource that was imported.- Parameters:
input- Input to be read.types- Number types for the columns of the DataSource.- Returns:
- DataSource Imported data.
- Throws:
java.io.IOException- when the file format is not valid or when experiencing an error during file operations.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG