Ok, so I have several text files, each of which contains more than 500,000 or even 1,000,000 lines.
I am currently doing something like this:
import random
def line_function(line):
def random_itteration(filepath):
with open(filepath) as f:
lines = f.readlines()
random.shuffle(lines)
for line in lines:
result = line_function(line)
The fact that Python Docs on random.shuffle()clearly stated (emphasis added by me):
Note that even for small len (x), the total number of permutations x can quickly grow more than the period of most random numbers generators. This means that most permutations of a long sequence can never be generated . For example, a sequence of length 2080 is the largest that can fit into the Mersenne Twister randomness period by a number generator.
, :
?
:
, line_function() , , . , .
, , , . , .
! Thnx .