# Class EcsvReader

java.lang.Object
uk.ac.starlink.ecsv.EcsvReader

All Implemented Interfaces:
  `Closeable, AutoCloseable`

public class EcsvReader extends Object implements 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

## Constructor Summary

Constructors
Constructor
Description
`EcsvReader(InputStream in, YamlParser yamlParser, MessagePolicy colCheck)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`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.
`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 Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### EcsvReader

public EcsvReader(InputStream in, YamlParser yamlParser, MessagePolicy colCheck) throws 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:
  `IOException`
  `EcsvFormatException`

## Method Details

### getMeta

public EcsvMeta getMeta()
Returns the ECSV metadata object used by this reader.

Returns:
  parsed metadata

### next

public boolean next() throws 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:
  `IOException`
  `EcsvFormatException`

### getCell

public 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 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 IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Throws:
  `IOException`