Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input_file = open('file.txt', 'r')
- for line in input_file:
- print line
- from itertools import islice
- with open('file.txt') as fin:
- lines = islice(fin, 1000000, 2000000) # or whatever ranges
- for line in lines:
- # do something
- import linecache
- for i in xrange(1000000, 2000000)
- print linecache.getline('file.txt', i)
- input_file = open('file.txt', 'r')
- for index, line in enumerate(input_file):
- # Assuming you start counting from zero
- if 1000000 <= index <= 2000000:
- print line
- 4.373 4.418 4.395 tail -n+50000000 test.in | head -n10
- 5.210 5.179 6.181 sed -n '50000000,50000010p;57890010q' test.in
- 5.525 5.475 5.488 head -n50000010 test.in | tail -n10
- 8.497 8.352 8.438 sed -n '50000000,50000010p' test.in
- 22.826 23.154 23.195 tail -n50000001 test.in | head -n10
- 25.694 25.908 27.638 ed -s test.in <<<"50000000,50000010p"
- 31.348 28.140 30.574 awk 'NR<57890000{next}1;NR==57890010{exit}' test.in
- 51.359 50.919 51.127 awk 'NR >= 57890000 && NR <= 57890010' test.in
- lines_data = []
- text_arr = multilinetext.split('n')
- for i in range(line_number_begin, line_number_end):
- lines_data.append(multilinetext[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement