The actual constructor is on the companion object.
The actual constructor is on the companion object.
All cells in a structure of nested IndexedSeq
s. The order is first rows, then columns.
A bidirectional map mapping rows to their row types and vice versa. Multiple rows can have the same type.
A bidirectional map mapping columns to their column types and vice versa. Multiple columns can have the same type.
User extensible metadata that is piggybacked in the Table
instance.
All cells in a structure of nested IndexedSeq
s.
All cells in a structure of nested IndexedSeq
s. The order is first rows, then columns.
The horizontal size of this table.
The horizontal size of this table. The table has strict rectangular form.
Unused cells simply contain empty StringCell
s.
A bidirectional map mapping columns to their column types and vice versa.
A bidirectional map mapping columns to their column types and vice versa. Multiple columns can have the same type.
This method is a shorthand for colTypes.reverse
.
This method is a shorthand for colTypes.reverse
.
a map from column types to matching ColKeys (column indices)
Get cell at specific row, column address.
Get cell keys corresponding to all cells on the specified column.
Get cell keys corresponding to all cells on the specified row.
Get all cells from the specified column
Get all cells from the specified row.
Get all cells in a single sequence.
Get all cells in a single sequence. One way to think about this is that the rows are catenated one after the other.
Get a full rows from table defined by rowType
.
Get a cell from specified row matching the specified column type.
Get a cell from specified row matching the specified column type. This method throws an error if more than 1 or zero cells match the criteria. Example:
// Get the user name cell from the 11th row. table.getSingleCell(RowKey(10), ColumnTypeUserName)
identifies the row to target.
identifies the column type which must correspond to exactly 1 column.
the matching cell object.
Otherwise same as getSingleCol(rowTypeMatcher, CT)
, but
the column is addressed directly with colKey
(column index).
Otherwise same as getSingleCol(rowTypeMatcher, CT)
, but
the column is addressed directly with colKey
(column index) and
a single bare row type is specified instead of the more general
predicate form.
Otherwise same as getSingleCol(rowTypeMatcher, CT)
, but
a single bare row type is specified instead of the more general
predicate form.
Gets a selected set of cells from a particular column.
Gets a selected set of cells from a particular column.
The cells will be picked from rows having a row type (RT
)
for which rowTypeMatcher
returns true.
Throws an exception if CT
fits more than one or zero columns.
Here is an imaginary example:
// Gets the street address for two types of addresses table.getSingleCol(Set(HomeAddressRow, BillingAddressRow), StreetAddressColumn)
Find a single column with given type.
Find a single column with given type. Throws if the number of columns with given type is not 1
Otherwise same as getSingleRow(RT, colTypeMatcher)
, but
row is addressed directly with RowKey
(row index).
Otherwise same as getSingleRow(RT, colTypeMatcher)
, but
row is addressed directly with RowKey
(row index) and
a single bare column type is specified instead of the more general
predicate form.
Otherwise same as getSingleRow(RT, colTypeMatcher)
, but
a single bare column type is specified instead of the more general
predicate form.
Gets a selected set of cells from a particular row.
Gets a selected set of cells from a particular row.
The cells will be picked from columns having a column type (CT
)
for which colTypeMatcher
returns true.
Throws an exception if RT
fits more than one or zero rows.
Here is an imaginary example:
// Gets the extra notes on projects and clients table.getSingleRow(ExtraNotesRow, Set(ProjectColumn, ClientColumn))
Find a single row with given type.
Find a single row with given type. Throws if the number of rows with given type is not 1
User extensible metadata that is piggybacked in the Table
instance.
Table can be "projected" ie.
Table can be "projected" ie. select some rows and columns and create a new table.
See TableProjection for an example.
Same as projection
, but start with all rows and columns which can
then be removed.
Same as projection
, but start with all rows and columns which can
then be removed.
See TableProjection for more details.
Returns a copy of the table with specified amounts of rows and columns added or removed.
Returns a copy of the table with specified amounts of rows and columns added or removed.
Basically the same as first doing resizedRows
and then resizedCols
.
Return a new table with different dimensions.
Return a new table with different dimensions.
The resizing is based on two rectangular regions targetRegion
and
resizedRegion
.
The idea is that this method can grow or shrink the region specified
by targetRegion
as needed to match the resizedRegion
.
defines a rectangular region of cells to be resized.
The idea is that targetRegion
will be resized to match
the resizedRegion
.
is a rectangular region to define the new size for the
targetRegion
.
The idea is that resizedRegion
can define
(span) a different rectangular region than the
targetRegion
.
If there are extra cells in the targetRegion
, rows and columns
are deleted from the "ends" of the targetRegion
.
If the resizedRegion
doesn't fit in targetRegion
, the
targetRegion
is expanded to contain it.
New rows and columns are generated with fillerGenerator
as needed.
There is one limitation however. The top left corner of
resizedRegion
must be equal to or towards down and right
with respect to the top left corner of targetRegion
.
When new cells need to be created, this is used. The cell does not need to have correct cellKey, a copy with the correct cellKey will be made if necessary.
Returns a modified a table with the specified amount of columns added or removed.
Returns a modified a table with the specified amount of columns added or removed.
where new columns are added or old ones deleted If columns are deleted this will be the first column to go and further columns will be the ones before this. If columns are added, they are added before this column with the same type as this column.
for negative values, rows left of colKey
are deleted.
For positive values columns at colKey
are added.
For zero, this table is returned.
Allows adding the new colums _after_ the column indicated by colKey
.
a modified copy of the table
Returns a modified a table with the specified amount of rows added or removed.
Returns a modified a table with the specified amount of rows added or removed.
where new rows are added or old rows deleted. If rows are deleted this will be the first row to go and further rows will be the ones before this. If rows are added, they are added after this row with the same type as this row.
for negative values, rows above rowKey
are deleted
For positive values rows at rowKey
are added.
For zero, this table is returned.
a modified copy of the table
The vertical size of this table.
The vertical size of this table. The table has strict rectangular form.
Unused cells simply contain empty StringCell
s.
A bidirectional map mapping rows to their row types and vice versa.
A bidirectional map mapping rows to their row types and vice versa. Multiple rows can have the same type.
This method is a shorthand for rowTypes.reverse
.
This method is a shorthand for rowTypes.reverse
.
a map from row types to matching RowKeys (row indices)
Return a new table with given cell replacing the previous cell
in the location cell.cellKey
.
A convenient form for returning a new table with specified cells updated.
A convenient form for returning a new table with specified cells updated.
val updated = table.updatedCells(StringCell(CellKey(0, 0), "foo"), StringCell(CellKey(1, 0), "bar"),
Return a new table with given cells replacing the previous cells
at each the location cell.cellKey
.
Return a new table with replacementCells
inserted into the table
as columns with the height of the targetRegion
.
Return a new table with replacementCells
inserted into the table
as columns with the height of the targetRegion
.
This method kind of squeezes given cells into the given region column by column.
If the given replacementCells
don't fit snugly into
the region, the region is resized horizontally as needed.
Another way to define this method, is that it is same as updatedRegion
,
but replacementCells
are renumbered from top to bottom and left to right
into the targetRegion
.
defines a rectangular region of cells to be replaced. Region
spanned by replacementCells
does not need to fit targetRegion.
Table will be resized to match. See below for more details.
a rectangular region of cells to replace targetRegion
.
Gaps are ok.
The replacementCells
can define (span) a different
rectangular region than the targetRegion.
See resized
for details on how the resizing works.
When new cells need to be created, this is used.
a new table with the replaced cells. Original table is not modified.
Return a new table with replacementCells
inserted into the table
as rows with the width of the targetRegion
.
Return a new table with replacementCells
inserted into the table
as rows with the width of the targetRegion
.
This method kind of squeezes given cells into the given region row by row.
If the given replacementCells
don't fit snugly into
the region, the region is resized vertically as needed.
Another way to define this method, is that it is same as updatedRegion
,
but replacementCells
are renumbered from left to right and top to
bottom into the targetRegion
.
This class is an immutable container for Cells with optional row and column types. The ideas in the API roughly follow popular spread sheet programs.
The cells are stored in rows which are numbered conceptually from top to bottom and then in columns which are numbered from left to right.
The row and column types are an additional abstraction with the purpose of simplifying machine reading of complex spread sheets.
This class is part of the the higher level API for reading, writing and processing CSV data.
The simpler stream based API is enough for many scenarios, but if several different sets of data will be pulled from the same CSV file and the structure of the CSV file is not rigid, this API may be a better fit.
Several methods are provided for getting cells based on the row and column types. For example
Example
This example constructs a table directly, although usually it is done via a TableReader. In this example, simple
String
values are used for row and column types, although usually an enumeration or case object type solution is cleaner and safer.Note on row and column numbers
Internally rows and columns have zero based index numbers, but in some cases like in
toString
methods ofCell
andCellKey
the index numbers are represented similarly to popular spread sheet programs. In that csae row numbers are one based and column numbers are alphabetic.The client specific row type.
The client specific column type.
The type of the
metadata
parameter. Must be a sub type of TableMetadata. This specifies the character set and separator to use when reading the CSV data from the input stream.All cells in a structure of nested
IndexedSeq
s. The order is first rows, then columns.A bidirectional map mapping rows to their row types and vice versa. Multiple rows can have the same type.
A bidirectional map mapping columns to their column types and vice versa. Multiple columns can have the same type.
User extensible metadata that is piggybacked in the
Table
instance.