TabularOutputFile

class TabularOutputFile(columnTypes: Map<String, DataType>, val path: Path) : TabularFile

An abstraction for writing rows of tabular data. Columns of the tabular data can be of numeric or text. Using this subclass of TabularFile users can write rows of data. The user is responsible for filling rows with data of the appropriate type for the column and writing the row to the file.

Use the static methods of TabularFile to create and define the columns of the file. Use the methods of this class to write rows. After writing the rows, it is important to call the flushRows() method to ensure that all buffered rows are committed to the file.

Parameters

columnTypes

a map that defines the column names and their data types

path

the path to the file for writing the data

See also

ksl.examples.utilities.TestTabularWork

For example code

Constructors

Link copied to clipboard
constructor(tabularData: TabularData, path: Path)

Uses tabularData as the schema pattern for defining the columns and their data types

constructor(columnTypes: Map<String, DataType>, path: Path)

Types

Link copied to clipboard
object Companion

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

Allows the user to configure the size of the batch writing if performance becomes an issue. This may or may not provide any benefit. The static methods related to this functionality can be used to recommend a reasonable batch size.

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

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

Opens the file as a TabularInputFile

Link copied to clipboard
fun checkTypes(elements: Array<Any?>): Boolean
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 flushRows()

After writing all rows, you must call flushRows() to ensure that all buffered row data is committed to the file.

Link copied to clipboard
fun isNumeric(colNum: Int): Boolean
Link copied to clipboard
fun isText(colNum: Int): Boolean
Link copied to clipboard

Returns the storage index of the numeric column at column index

Link copied to clipboard

Provides a row that can be used to set individual columns before writing the row to the file

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

A convenience method. This writes the values in the array to the numeric columns in the file in the order of their appearance. Any text columns will have the value null and cannot be unwritten.

Link copied to clipboard

Writes the data represented by the TabularData instance to the file. The operation cannot be undone.

fun writeRow(rowSetter: RowSetterIfc)

Writes the data currently in the row to the file. Once written, the operation cannot be undone.

Link copied to clipboard

A convenience method if the user has a list of rows to write. All rows in the list are written to the file.

Link copied to clipboard
fun writeText(data: Array<String?>)

A convenience method. This writes the values in the array to the text columns in the file in the order of their appearance. Any numeric columns will have the value Double.NaN and cannot be unwritten.