shlogg · Early preview
Judy @esproc_spl

How To Repeat Rows In Txt File Based On Number M

We have a txt file with N+1 rows. Repeat row N M times and get an altogether N*M rows. Write a script in esProc to achieve this, then integrate it with a Java program using @i option for sequence return.

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