Package uk.ac.starlink.ecsv
Class EcsvReader
java.lang.Object
uk.ac.starlink.ecsv.EcsvReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
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
ConstructorsConstructorDescriptionEcsvReader
(InputStream in, YamlParser yamlParser, MessagePolicy colCheck) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
getCell
(int icol) Returns the contents of a cell in the current row.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.
-
Constructor Details
-
EcsvReader
public EcsvReader(InputStream in, YamlParser yamlParser, MessagePolicy colCheck) throws 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:
IOException
EcsvFormatException
-
-
Method Details
-
getMeta
Returns the ECSV metadata object used by this reader.- Returns:
- parsed metadata
-
next
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:
IOException
EcsvFormatException
-
getCell
Returns the contents of a cell in the current row.- Returns:
- the contents of cell
icol
in the current row
-
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
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-