Class GavoCSVTableParser
We follow and expand on the specification for CSV files as detailed in http://www.edoceo.com/utilis/csv-file-format.php. We expand on this by allowing zero, one or more header lines. If header lines are there, we assume the last one to give the names of the columns. By default we assume 1 header line is available, the actual number may be set in the appropriate parseCSV method.
We do allow for delimiters different from a comma, but we treat their occurence exactly as otherwise the comma would be treated according to the specification.
We do NOT allow for string demarcations different from the double-quote.
A a final touch we allow for "comment" lines starting with a comment string. Lines starting with the comment string (e.g. ";;") will be ignored (but see next paragraph). This is needed in order to be able to successfully parse CSV files as output by CDS/Vizier, or the GAVO "simpledb" web applications.
Addition: we assume that there are comment lines starting with "#COLUMN" which indicate metadata about all the columns. We assume that the first line without "#" symbol contains the column names. All subsequent rows are data.
- Author:
- Gerard Lemson, Hans-Martin Adorf, Gerard Lemson, Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRecursive descent parser for parsing a single line -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGavoCSVTableParser(uk.ac.starlink.table.StoragePolicy storage, Component parent) Creates a new instance of CSVTableParserGavoCSVTableParser(uk.ac.starlink.table.StoragePolicy storage, Component parent, String delimiter) Creates a new instance of CSVTableParser -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?> classForJDBCType(int jdbcType) Getter for property commentPrefix.Gets the delimiter.static ObjectobjectForJDBCType(int jdbcType, String value) uk.ac.starlink.table.StarTableparse(InputStream stream) Return a List of tokens (Strings) from the specified line, delimited by the specified delimiter.voidsetDelimiter(String delimiter) Sets the delimiter to use.
-
Field Details
-
DEFAULT_DELIMITER
-
DEFAULT_COMMENT_PREFIX
-
-
Constructor Details
-
GavoCSVTableParser
Creates a new instance of CSVTableParser -
GavoCSVTableParser
-
-
Method Details
-
getCommentPrefix
Getter for property commentPrefix.- Returns:
- Value of property commentPrefix.
-
setDelimiter
Sets the delimiter to use.- Parameters:
delimiter- the delimiter.
-
getDelimiter
-
parseLine
-
parse
- Throws:
Exception
-
classForJDBCType
-
objectForJDBCType
-