Problem description & analysis
We have a txt file txt.txt, as shown below:
a brown frog leaps over a lazy dog
the dog then chases it’s own tail
the tail is long and brown
the brown frog goes for a swim
3
The following text file has N+1 rows, in which row (N+1) contains a number M, say 3. We are trying to generate a new file according to this file. The rule is that repeat row N M times and get an altogether N*M rows, as shown below:
a brown frog leaps over a lazy dog
the dog then chases it’s own tail
the tail is long and brown
the brown frog goes for a swim
a brown frog leaps over a lazy dog
the dog then chases it’s own tail
the tail is long and brown
the brown frog goes for a swim
a brown frog leaps over a lazy dog
the dog then chases it’s own tail
the tail is long and brown
the brown frog goes for a swim
Solution
Write the following script p1.dfx in esProc:
A1 Import the txt data. @i option enables returning a sequence if the result set contains only one column.
A2 Copy the sequence from which the last member is removed the integer times which is value of the last member.
A3 Export A2’s result to result.txt.
Find how to integrate the script code with a Java program in How to Call an SPL Script in Java.
Source link
lol