Documentation of 'de.erichseifert.gral.io.data.CSVReader' Java class
CSVReader
de.erichseifert.gral.io.data

Class CSVReader

  • All Implemented Interfaces:
    DataReader


    public class CSVReader
    extends AbstractDataReader

    Class that creates a DataSource from 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.

    CSVReader instances should be obtained by the DataReaderFactory rather 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.String SEPARATOR_CHAR
      Key for specifying a Character value 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.
    • Field Detail

      • SEPARATOR_CHAR

        public static final java.lang.String SEPARATOR_CHAR
        Key for specifying a Character value 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

You see the box below because you did not login.