I\'m using a for loop to read a file, but I only want to read specific lines, say line #26 and #30. Is there any built-in feature to achieve this?
Thanks
If your large text file file is strictly well-structured (meaning every line has the same length l), you could use for n-th line
file
l
n
with open(file) as f: f.seek(n*l) line = f.readline() last_pos = f.tell()
Disclaimer This does only work for files with the same length!