Package ca.spatial.util
Class CSVTableReader
java.lang.Object
ca.spatial.util.CSVTableReader
- All Implemented Interfaces:
TableReader
Read data from a CSV file.
Forward-only cursor operations are supported.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
The maximum number of data columns allowed.static int
The maximum record size allowed. -
Constructor Summary
ConstructorsConstructorDescriptionCSVTableReader(File file)
CSVTableReader(File file, String reselect)
CSVTableReader(String filename)
CSVTableReader(String filename, String reselect)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
assertColumns(String[] columns)
Check to see that the desired columns are presentvoid
close()
Close the cursor and dispose of resources.static void
copyTable(TableReader reader, String outputName)
Copy a table to a text file, in simple CSV formatbyte[]
digest()
Get the SHA1 digest for this input stream.static boolean
getColumnName(int index)
Get the name of a column.String[]
Get an array of all column labelsint
getColumnPos(String label)
Get the position of a given column namegetField(int index)
Get the contents of a field, by position.Get the contents of a field, by name.boolean
getNext()
Advance the cursor to the next record.int
Get the number of columnsstatic boolean
open()
Prepare the cursor for usevoid
Set a Task object to report on progress
-
Field Details
-
MAX_COLUMNS
public static final int MAX_COLUMNSThe maximum number of data columns allowed.- See Also:
- Constant Field Values
-
MAX_RECORD_LENGTH
public static final int MAX_RECORD_LENGTHThe maximum record size allowed.- See Also:
- Constant Field Values
-
-
Constructor Details
-
CSVTableReader
-
CSVTableReader
-
CSVTableReader
-
CSVTableReader
-
-
Method Details
-
open
Description copied from interface:TableReader
Prepare the cursor for use- Specified by:
open
in interfaceTableReader
- Throws:
TableReaderException
-
exists
-
isGZIP
-
getColumnName
Description copied from interface:TableReader
Get the name of a column.- Specified by:
getColumnName
in interfaceTableReader
-
getColumnNames
Description copied from interface:TableReader
Get an array of all column labels- Specified by:
getColumnNames
in interfaceTableReader
-
getNumberOfColumns
public int getNumberOfColumns()Description copied from interface:TableReader
Get the number of columns- Specified by:
getNumberOfColumns
in interfaceTableReader
-
getColumnPos
Description copied from interface:TableReader
Get the position of a given column name- Specified by:
getColumnPos
in interfaceTableReader
-
assertColumns
Description copied from interface:TableReader
Check to see that the desired columns are present- Specified by:
assertColumns
in interfaceTableReader
-
getField
Description copied from interface:TableReader
Get the contents of a field, by name. Returns null if the field does not exist or an error occurs.- Specified by:
getField
in interfaceTableReader
-
getField
Description copied from interface:TableReader
Get the contents of a field, by position. Returns null if the field does not exist or an error occurs.- Specified by:
getField
in interfaceTableReader
-
getNext
Description copied from interface:TableReader
Advance the cursor to the next record.- Specified by:
getNext
in interfaceTableReader
- Returns:
- true if the another record is available in the cursor.
- Throws:
TableReaderException
-
close
public void close()Description copied from interface:TableReader
Close the cursor and dispose of resources.- Specified by:
close
in interfaceTableReader
-
setTask
Description copied from interface:TableReader
Set a Task object to report on progress- Specified by:
setTask
in interfaceTableReader
-
copyTable
public static void copyTable(TableReader reader, String outputName) throws IOException, TableReaderExceptionCopy a table to a text file, in simple CSV format- Throws:
IOException
TableReaderException
-
digest
public byte[] digest()Description copied from interface:TableReader
Get the SHA1 digest for this input stream.- Specified by:
digest
in interfaceTableReader
-