TabularInputFile

An abstraction for reading rows of tabular data. Columns of the tabular data can be of numeric or text. Using this subclass of TabularFile users can read rows of data. The user is responsible for iterating rows with data of the appropriate type for the column and reading the row into their program.

Use the static methods of TabularFile to create and define the columns of the file. Use the methods of this class to read rows.

See also

ksl.examples.utilities.TestTabularWork

For example code

Constructors

Link copied to clipboard
constructor(path: Path)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
inner class RowIterator(startingRowNum: Long = 1) : Iterator<RowGetterIfc>

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val path: Path
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Transforms the file into an SQLite database file

Link copied to clipboard
open override fun asDataFrame(): AnyFrame

Converts the columns and rows to a Dataframe.

Link copied to clipboard
fun checkTypes(elements: Array<Any?>): Boolean
Link copied to clipboard
fun close()

Remember to close the file after all processing

Link copied to clipboard
fun columnIndex(name: String): Int
Link copied to clipboard
fun columnIndexForNumeric(storageIndex: Int): Int

Returns the column index associated with the storage index

Link copied to clipboard
fun columnIndexForText(storageIndex: Int): Int

Returns the column index associated with the storage index

Link copied to clipboard
fun columnName(colNum: Int): String
Link copied to clipboard
fun dataType(colNum: Int): DataType
Link copied to clipboard
fun exportToCSV(out: PrintWriter, header: Boolean = true)

Writes the data in the file to a CSV file

Link copied to clipboard
fun exportToExcelWorkbook(wbName: String, wbDirectory: Path)

This is not optimized for large files and may have memory and performance issues.

Link copied to clipboard
fun fetchNumericColumn(columnNum: Int, maxRows: Int = 0, removeMissing: Boolean = false): DoubleArray
fun fetchNumericColumn(columnName: String, maxRows: Int = 0, removeMissing: Boolean = false): DoubleArray

Obviously, there are memory issues if there are a lot of rows.

Link copied to clipboard
fun fetchRow(rowNum: Long): RowGetterIfc

Returns the row. If the provided row number is larger than the number of rows in the file then an exception is thrown. Use fetchRow() if you do not check the number of rows.

Link copied to clipboard
fun fetchRows(minRowNum: Long, maxRowNum: Long): List<RowGetterIfc>

Returns the rows between minRowNum and maxRowNum, inclusive. Since there may be memory implications when using this method, please use it wisely. In fact, use the provided iterator instead.

Link copied to clipboard
fun fetchTextColumn(columnNum: Int, maxRows: Int = 0, removeMissing: Boolean = false): Array<String?>
fun fetchTextColumn(columnName: String, maxRows: Int = 0, removeMissing: Boolean = false): Array<String?>

Obviously, there are memory issues if there are a lot of rows.

Link copied to clipboard
fun isNumeric(colNum: Int): Boolean
Link copied to clipboard
fun isText(colNum: Int): Boolean
Link copied to clipboard
Link copied to clipboard
fun numericColumns(maxRows: Int = 0, removeMissing: Boolean = false): Map<String, DoubleArray>
Link copied to clipboard

Returns the storage index of the numeric column at column index

Link copied to clipboard
fun printAsText(minRowNum: Long = 1, maxRowNum: Long = minRowNum + 10)

This is not optimized for large files and may have memory and performance issues.

Link copied to clipboard
fun textColumns(maxRows: Int = 0, removeMissing: Boolean = false): Map<String, Array<String?>>
Link copied to clipboard
fun textStorageIndex(colNum: Int): Int

Returns the storage index of the text column at column index

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun writeAsText(out: PrintWriter, minRowNum: Long = 1, maxRowNum: Long = totalNumberRows)

This is not optimized for large files and may have memory and performance issues.