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.
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.