Randomly selected subset of lines from a text file
Posted: 25 Nov 2012 22:46
Folks,
I've done a lot of research and cannot seem to determine how to write a simple batch file that will select a subset of all the lines in a text file and echos on the screen. I am thinking of the following three steps:
If I want the subset to be 10%, I will set the treshold to 0.10 assuming that the random numbers that DOS will generate will be between 0 and 1.
Thank you for your help,
-Roger
I've done a lot of research and cannot seem to determine how to write a simple batch file that will select a subset of all the lines in a text file and echos on the screen. I am thinking of the following three steps:
Code: Select all
For each line in a text file
{
Generate random number
If random number < treshold, echo line
}
If I want the subset to be 10%, I will set the treshold to 0.10 assuming that the random numbers that DOS will generate will be between 0 and 1.
Thank you for your help,
-Roger