Package uk.ac.starlink.ecsv
Class EcsvReader
- java.lang.Object
-
- uk.ac.starlink.ecsv.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
-
-
Constructor Summary
Constructors Constructor Description EcsvReader(java.io.InputStream in, YamlParser yamlParser, MessagePolicy colCheck)
Constructor.
-
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.
-
-
-
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 bufferedyamlParser
- knows how to extrace ECSV metadata from YAMLcolCheck
- 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 thegetCell(int)
orgetRow()
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-