python Programming Glossary: input.readline
Python random N lines from large file (no duplicate lines) http://stackoverflow.com/questions/12279017/python-random-n-lines-from-large-file-no-duplicate-lines lines for i in range int options.header output.write input.readline usedPositions.append input.tell # Find and write all random.. # Seek to random position in file probably middle of line input.readline # Read the line probably incomplete . Next input.readline results.. input.readline # Read the line probably incomplete . Next input.readline results in a complete line. while input.tell in usedPositions..
|