Example usage for org.jfree.data.io CSV readCategoryDataset

List of usage examples for org.jfree.data.io CSV readCategoryDataset

Introduction

In this page you can find the example usage for org.jfree.data.io CSV readCategoryDataset.

Prototype

public CategoryDataset readCategoryDataset(Reader in) throws IOException 

Source Link

Document

Reads a CategoryDataset from a CSV file or input source.

Usage

From source file:de.xirp.chart.ChartUtil.java

/**
 * Returns a {@link org.jfree.data.category.CategoryDataset}
 * generated from a CSV {@link java.io.File}.
 * //from w  w w  . j  a  v a  2  s. c o  m
 * @param csvFile
 *            The file to read the values from.
 * @return A <code>CategoryDataset</code> generated from a csv
 *         file.
 * @see org.jfree.data.category.CategoryDataset
 */
public static CategoryDataset getCategoryDatasetFromCSV(File csvFile) {
    CSV csv = new CSV(',', '"');
    CategoryDataset dataset = null;
    try {
        FileReader fr = new FileReader(csvFile);
        dataset = csv.readCategoryDataset(fr);
    } catch (FileNotFoundException e) {
        logClass.error("Error: " + e.getMessage() //$NON-NLS-1$
                + Constants.LINE_SEPARATOR, e);
    } catch (IOException e) {
        logClass.error("Error: " + e.getMessage() //$NON-NLS-1$
                + Constants.LINE_SEPARATOR, e);
    }
    return dataset;
}