# Read to a specific line in a file import os import linecache # Change to directory where script is located abspath = os.path.abspath(__file__) dname = os.path.dirname(abspath) os.chdir(dname) line = linecache.getline('Gas.txt', 150002) print line line = linecache.getline('Gas.txt', 15) print line line = linecache.getline('Gas.txt', 64002) print line