Class EcsvReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class EcsvReader
    extends java.lang.Object
    implements java.io.Closeable
    Parser for the metadata and data of an ECSV file. The format currently supported is ECSV 1.0, as documented at Astropy APE6.
    Since:
    28 Apr 2020
    Author:
    Mark Taylor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.lang.Object getCell​(int icol)
      Returns the contents of a cell in the current row.
      EcsvMeta getMeta()
      Returns the ECSV metadata object used by this reader.
      java.lang.Object[] getRow()
      Returns the contents of the current row, as an array with one element per column.
      boolean next()
      Attempts to advance the current row to the next one.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EcsvReader

        public EcsvReader​(java.io.InputStream in,
                          YamlParser yamlParser,
                          MessagePolicy colCheck)
                   throws java.io.IOException,
                          EcsvFormatException
        Constructor.
        Parameters:
        in - input stream; doesn't need to be buffered
        yamlParser - knows how to extrace ECSV metadata from YAML
        colCheck - what to do on CSV/YAML column name mismatches
        Throws:
        java.io.IOException
        EcsvFormatException
    • Method Detail

      • getMeta

        public EcsvMeta getMeta()
        Returns the ECSV metadata object used by this reader.
        Returns:
        parsed metadata
      • next

        public boolean next()
                     throws java.io.IOException,
                            EcsvFormatException
        Attempts to advance the current row to the next one. This method must be called before current row data can be accessed using the getCell(int) or getRow() methods.
        Returns:
        true if this sequence has been advanced to the next row, false if there are no more rows
        Throws:
        java.io.IOException
        EcsvFormatException
      • getCell

        public java.lang.Object getCell​(int icol)
        Returns the contents of a cell in the current row.
        Returns:
        the contents of cell icol in the current row
      • getRow

        public java.lang.Object[] getRow()
        Returns the contents of the current row, as an array with one element per column.
        Returns:
        an array of the objects in each cell
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException