public class CSV
extends java.lang.Object
CategoryDataset data from a CSV file.
This initial version is very basic, and won't handle errors in the data
file very gracefully.| Modifier and Type | Field and Description |
|---|---|
private char |
fieldDelimiter
The field delimiter.
|
private char |
textDelimiter
The text delimiter.
|
| Constructor and Description |
|---|
CSV()
Creates a new CSV reader where the field delimiter is a comma, and the
text delimiter is a double-quote.
|
CSV(char fieldDelimiter,
char textDelimiter)
Creates a new reader with the specified field and text delimiters.
|
| Modifier and Type | Method and Description |
|---|---|
private java.util.List |
extractColumnKeys(java.lang.String line)
Extracts the column keys from a string.
|
private void |
extractRowKeyAndData(java.lang.String line,
DefaultCategoryDataset dataset,
java.util.List columnKeys)
Extracts the row key and data for a single line from the input source.
|
CategoryDataset |
readCategoryDataset(java.io.Reader in)
Reads a
CategoryDataset from a CSV file or input source. |
private java.lang.String |
removeStringDelimiters(java.lang.String key)
Removes the string delimiters from a key (as well as any white space
outside the delimiters).
|
private char fieldDelimiter
private char textDelimiter
public CSV()
public CSV(char fieldDelimiter,
char textDelimiter)
fieldDelimiter - the field delimiter (usually a comma, semi-colon,
colon, tab or space).textDelimiter - the text delimiter (usually a single or double
quote).public CategoryDataset readCategoryDataset(java.io.Reader in) throws java.io.IOException
CategoryDataset from a CSV file or input source.in - the input source.java.io.IOException - if there is an I/O problem.private java.util.List extractColumnKeys(java.lang.String line)
line - a line from the input file.private void extractRowKeyAndData(java.lang.String line,
DefaultCategoryDataset dataset,
java.util.List columnKeys)
line - the line from the input source.dataset - the dataset to be populated.columnKeys - the column keys.private java.lang.String removeStringDelimiters(java.lang.String key)
key - the key (including delimiters).