Modify a range of rows after applying transformations
I want to write a kiba transformation that allows me to insert the same information for an specific number of rows. In this case i have an xls file that contains subheaders, and this subheaders contain data as well, like this:
Client: John Doe, Code: 1234
qty, date, price
1, 12/12/2017, 300.00
6, 12/12/2017, 300.00
total: 2100
Client: Nick Leitgeb, Code: 2345
qty, date, price
1, 12/12/2017, 100.00
2, 12/12/2017, 200.00
2, 12/12/2017, 50.00
total: 600
Client: …..
In order to extract relevant data i use the next transformation, which returns rows that matches at least one regex of the two provided (a date or the ‘Client’ word)
transform, SelectByRegexes regex: [/\d+\/\d+\/\d+/, /Client:/], matches: 1
This will give me the next result:
Client: John Doe, Code: 1234
1, 12/12/2017, 300.00
6, 12/12/2017, 300.00
Client: Nick Leitgeb, Code: 2345
1, 12/12/2017, 100.00
2, 12/12/2017, 200.00
2, 12/12/2017, 50.00
…..
Now that i have the information that i want, i need to replicate the client and the code for each sub row, and delete the subheader
John Doe, 1234, 1, 12/12/2017, 300.00
John Doe, 1234, 6, 12/12/2017, 300.00
Nick Leitgeb, 2345, 1, 12/12/2017, 100.00
Nick Leitgeb, 2345, 2, 12/12/2017, 200.00
Nick Leitgeb, 2345, 2, 12/12/2017, 50.00
The only way i can think to do this, is by doing it directly on the source
or in a pre_process
block, but will need the transformations
used before in order to show the necessary data, is it possible to use a transformation class inside the source/pre_process block?,
or manipulating multiple rows in a transformation ?