Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. input_file = open('file.txt', 'r')
  2. for line in input_file:
  3. print line
  4.  
  5. from itertools import islice
  6. with open('file.txt') as fin:
  7. lines = islice(fin, 1000000, 2000000) # or whatever ranges
  8. for line in lines:
  9. # do something
  10.  
  11. import linecache
  12.  
  13. for i in xrange(1000000, 2000000)
  14. print linecache.getline('file.txt', i)
  15.  
  16. input_file = open('file.txt', 'r')
  17. for index, line in enumerate(input_file):
  18. # Assuming you start counting from zero
  19. if 1000000 <= index <= 2000000:
  20. print line
  21.  
  22. 4.373 4.418 4.395 tail -n+50000000 test.in | head -n10
  23. 5.210 5.179 6.181 sed -n '50000000,50000010p;57890010q' test.in
  24. 5.525 5.475 5.488 head -n50000010 test.in | tail -n10
  25. 8.497 8.352 8.438 sed -n '50000000,50000010p' test.in
  26. 22.826 23.154 23.195 tail -n50000001 test.in | head -n10
  27. 25.694 25.908 27.638 ed -s test.in <<<"50000000,50000010p"
  28. 31.348 28.140 30.574 awk 'NR<57890000{next}1;NR==57890010{exit}' test.in
  29. 51.359 50.919 51.127 awk 'NR >= 57890000 && NR <= 57890010' test.in
  30.  
  31. lines_data = []
  32. text_arr = multilinetext.split('n')
  33. for i in range(line_number_begin, line_number_end):
  34. lines_data.append(multilinetext[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement