title: Python - Loadtext with specific lines for huge file
body: <p>I have to get specific lines in a huge text file. Until now i try as below. My aim is to extract columns for a specific iteration, here each 500 lines. But by proceeding with the "readlines", sometimes i get some crashes because of the size of the file (until 4Gb).
  So i would like to find an other way in order to avoid problems...</p>
  
  <pre><code>with open('/test.txt') as f:
      text = f.readlines()
  
  
  A = ""    
  for i in text[3000:3500]:
    A+=i
  
  B=A.splitlines()
  listed = []
  for i in range(len(B)):
    C=B[i][3:47].split(" ")
  
    while True:
      try:
        C.remove("")
      except ValueError:
        break
    listed.append(C)
  
  import numpy as np
  import matplotlib.pyplot as plt
  
  #print listed
  x = np.array(listed, dtype=float)
  y = x.astype(np.float)
  
  plt.plot(y[:,1]);plt.ylim(0,5);plt.show()
  </code></pre>
  
  <p>This post follows a former <a href="https://stackoverflow.com/questions/32559304/python-loadtext-for-specific-number-of-lines">question</a>.</p>