Is there a Python file type for accessing random lines without traversing the whole file? I need to search within a large file, reading the whole thing into memory wouldn\'t
You can use linecache:
import linecache print linecache.getline(your_file.txt, randomLineNumber) # Note: first line is 1, not 0