RawTableTransformation

com.phasmidsoftware.tableparser.core.table.RawTableTransformation
case class RawTableTransformation(transformers: Map[String, Transformation[String, String]]) extends Transformation[RawTable, RawTable]

A transformation class that applies a specific set of transformations to the rows of a RawTable based on matching column names.

Value parameters

transformers

A map where the keys are column names (as String) and the values are Transformation[String, String] instances, which define how to transform data in the corresponding columns. This class implements the Transformation[RawTable, RawTable] trait, meaning it takes a RawTable as input and produces a transformed RawTable as output. The transformation process is based on matching column names from the transformers map with the column names in the table's header. If a match is found, the corresponding transformation is applied to the relevant column in each row of the table. ==Example Usage== To use this class, first construct a RawTableTransformation instance by providing a map of column names and their corresponding transformations:

val transformers: Map[String, Transformation[String, String]] = Map(
 "column1" -> CustomTransformation1,
 "column2" -> CustomTransformation2
)
val transformation = RawTableTransformation(transformers)
// Apply the transformation to a RawTable object
val transformedTable = transformation(rawTable)
               ==Implementation Details==
  • The apply method retrieves the table's maybeHeader object, which contains the column names.
  • For each column name in the transformers map, it fetches the column index using Header.getIndex.
  • The transformations are then compiled into a map associating column indices with their respective transformations.
  • Finally, the table's rows are transformed using the map method, which applies a RawRowTransformation to each row.

Attributes

See also
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait RawTable => RawTable
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Applies a set of transformations to a given RawTable. The transformations are selectively applied based on the column indices determined by matching keys in the transformers map with the column headers (if available) in the input table.

Applies a set of transformations to a given RawTable. The transformations are selectively applied based on the column indices determined by matching keys in the transformers map with the column headers (if available) in the input table.

Value parameters

t

the input RawTable which is a representation of a table containing rows and optionally headers. Each row in the table may be transformed based on the transformations for matching columns.

Attributes

Returns

a new RawTable where each row is transformed according to the applicable transformations.

Inherited methods

def andThen[A](g: RawTable => A): RawTable => A

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters

A

the result type of function g

Value parameters

g

a function R => A

Attributes

Returns

a new function f such that f(x) == g(apply(x))

Inherited from:
Function1
def compose[A](g: A => RawTable): A => RawTable

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters

A

the type to which function g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Function1 -> Any
Inherited from:
Function1